HERE Android SDK Developer's Guide

PositioningManager

The class PositioningManager is a member of com.here.android.mpa.common .

Class Summary

public final class PositioningManager

extends java.lang.Object

Represents a manager for information received from positioning devices, such as updates to the current position and the average speed.

[For complete information, see the section Class Details]

Nested Class Summary

Table 1. Nested Classes in PositioningManager
Nested Classes

public static final enumeration PositioningManager.LocationMethod

Represents values describing the location method.

public static final enumeration PositioningManager.LocationStatus

Represents values describing the location status of a particular location method.

public static abstract interface PositioningManager.OnPositionChangedListener

Represents an interface for position update listeners.

Method Summary

Table 2. Methods in PositioningManager
Methods

public void addListener (java.lang.ref.WeakReference <OnPositionChangedListener> listener)

Adds a PositioningManager.OnPositionChangedListener to the PositioningManager .

public double getAverageSpeed ()

Gets the average speed of travel, in meters per second.

public static PositioningManager getInstance ()

Get access to the PositioningManager Singleton

public GeoPosition getLastKnownPosition ()

Returns the last known (cached) position from the best available provider.

public LocationMethod getLocationMethod ()

Gets the method type used to determine positioning.

public LocationStatus getLocationStatus (LocationMethod method)

Gets the status for a specified LocationMethod .

public GeoPosition getPosition ()

Gets the GeoPosition for the current PositioningManager.LocationMethod if available.

public boolean hasValidPosition ()

Determines whether the current position for the current active PositioningManager.LocationMethod is valid.

public boolean hasValidPosition (LocationMethod method)

Determines whether the current position for the specified LocationMethod is valid.

public boolean isActive ()

Determines whether the PositioningManager is active and whether position updates are being received.

public void removeListener (OnPositionChangedListener listener)

Removes a PositioningManager.OnPositionChangedListener from the PositioningManager .

public boolean start (LocationMethod method)

Starts receiving position updates from the positioning device.

public void stop ()

Stops receiving position updates from the positioning device.

Class Details

Represents a manager for information received from positioning devices, such as updates to the current position and the average speed.

If the user of the application revokes the ACCESS_FINE_LOCATION permission at runtime while PositioningManager is active, the application will stop receiving location updates and methods of PositioningManager will stop functioning properly until the ACCESS_FINE_LOCATION permission is restored.

Method Details

public void addListener (java.lang.ref.WeakReference <OnPositionChangedListener> listener)

Adds a PositioningManager.OnPositionChangedListener to the PositioningManager .

Parameters:

  • listener

    A OnPositionChangedListener to add

See also:

removeListener(OnPositionChangedListener)

public double getAverageSpeed ()

Gets the average speed of travel, in meters per second.

Returns:

The average speed

public static PositioningManager getInstance ()

Get access to the PositioningManager Singleton

Returns:

PositioningManager instance

public GeoPosition getLastKnownPosition ()

Returns the last known (cached) position from the best available provider. This is useful if there is no valid device position available (i.e. hasValidPosition() returns false). If hasValidPosition() returns true, please use the getPosition() API.

Returns:

Last known position from the best available provider.

See also:

getPosition()

public LocationMethod getLocationMethod ()

Gets the method type used to determine positioning.

Returns:

The LocationMethod

public LocationStatus getLocationStatus (LocationMethod method)

Gets the status for a specified LocationMethod .

Parameters:

  • method

    A LocationMethod used to determine the location status

Returns:

The status of the specified LocationMethod

public GeoPosition getPosition ()

Gets the GeoPosition for the current PositioningManager.LocationMethod if available.

Availability of a position can be checked by way of the hasValidPosition() method, if that method returns false, the best available cached position can be obtained using the getLastKnownPosition() API.

The position returned is determined by the following criteria:

Returns:

The current GeoPosition

See also:

getLastKnownPosition()

public boolean hasValidPosition ()

Determines whether the current position for the current active PositioningManager.LocationMethod is valid.

Returns:

True if the position is valid, false otherwise

See also:

hasValidPosition(LocationMethod)

public boolean hasValidPosition (LocationMethod method)

Determines whether the current position for the specified LocationMethod is valid.

Parameters:

  • method

    A LocationMethod to check for a valid position

Returns:

True if the position is valid, false otherwise

See also:

hasValidPosition()

public boolean isActive ()

Determines whether the PositioningManager is active and whether position updates are being received.

Returns:

True if the PositioningManager is actively receiving position updates, false otherwise

public void removeListener (OnPositionChangedListener listener)

Removes a PositioningManager.OnPositionChangedListener from the PositioningManager .

Parameters:

  • listener

    A OnPositionChangedListener to remove

See also:

addListener(WeakReference<OnPositionChangedListener>)

public boolean start (LocationMethod method)

Starts receiving position updates from the positioning device.

The PositioningManager will not be started if the application does not have the {@code ACCESS_FINE_LOCATION) permission at the time of this call.

Parameters:

  • method

    A LocationMethod used to provide position updates

Returns:

true if position updates have started being received from the positioning device, false otherwise.

public void stop ()

Stops receiving position updates from the positioning device.