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
Nested Classes |
---|
Represents values describing the location method. |
Represents values describing the location status of a particular location method. |
Represents an interface for position update listeners. |
Method Summary
Methods |
---|
Adds a PositioningManager.OnPositionChangedListener to the |
Gets the average speed of travel, in meters per second. |
Get access to the PositioningManager Singleton |
Returns the last known (cached) position from the best available provider. |
Gets the method type used to determine positioning. |
Gets the status for a specified |
Gets the GeoPosition for the current PositioningManager.LocationMethod if available. |
Determines whether the current position for the current active PositioningManager.LocationMethod is valid. |
Determines whether the current position for the specified |
Determines whether the |
Removes a PositioningManager.OnPositionChangedListener from the |
Starts receiving position updates from the positioning device. |
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:
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:
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:
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:
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:
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:
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 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.