A singleton which provides methods for controlling navigation.
All methods are guaranteed to be thread-safe except for setAudioGuidance and setHeadsUpNotificationEnabled which must be called on the UI thread.
Nested Class Summary
interface | Navigator.ArrivalListener | Defines signatures for methods that are called when the driver arrives at a waypoint. | |
@interface | Navigator.AudioGuidance | AudioGuidance is a set of flags used to specify what kinds of audio alerts and guidance are used during navigation. | |
interface | Navigator.RemainingTimeOrDistanceChangedListener | Defines signatures for methods that are called when the remaining time or distance to the next destination changes. | |
interface | Navigator.RouteChangedListener | Defines signatures for methods that are called when the route changes. | |
enum | Navigator.RouteStatus | A RouteStatus is a status code that represents the result of a route calculation, accessed via
the Future returned by setDestination(Waypoint) . |
Public Method Summary
abstract void |
cleanup()
Cleans up internal state of the Navigator.
|
abstract void |
clearDestinations()
Clears all previously set destinations and removes any calculated routes from the map.
|
abstract void |
clearLicensePlateRestrictionInfo()
Clears license plate information about the current driver.
|
abstract void |
clearRemainingTimeOrDistanceChangedListener()
Clears the listener for changes in remaining time or distance.
|
abstract Waypoint |
continueToNextDestination()
Removes the current destination.
|
abstract ListenableResultFuture<RouteInfo> |
fetchRouteInfo(Waypoint waypoint, RoutingOptions routingOptions)
Returns route information for routes based on each value of
RoutingOptions.RoutingStrategy . |
abstract RouteSegment |
getCurrentRouteSegment()
Returns the current leg of the journey.
|
abstract TimeAndDistance |
getCurrentTimeAndDistance()
Returns the estimated time and distance from the current position to the current destination.
|
abstract List<RouteSegment> |
getRouteSegments()
Returns a list of route segments.
|
abstract Simulator |
getSimulator()
Returns a Simulator object, for use during testing.
|
abstract List<TimeAndDistance> |
getTimeAndDistanceList()
Returns a list of times and distances corresponding to each destination in the current route,
representing the estimated time and distance from the current position to each destination.
|
abstract List<LatLng> |
getTraveledRoute()
Returns the route traveled so far during this guidance session (since the last call to
startGuidance() ). |
abstract boolean |
isGuidanceRunning()
Returns
true if guidance is currently running. |
abstract void | |
abstract void |
setAudioGuidance(int guidance)
Sets which types of audio guidance (including vibration) are enabled.
|
abstract ListenableResultFuture<Navigator.RouteStatus> |
setDestination(Waypoint destination, RoutingOptions routingOptions, DisplayOptions displayOptions)
Sets a single destination for navigation, overriding any previously set destinations.
|
abstract ListenableResultFuture<Navigator.RouteStatus> |
setDestination(Waypoint destination, RoutingOptions options)
Sets a single destination for navigation, overriding any previously set destinations.
|
abstract ListenableResultFuture<Navigator.RouteStatus> |
setDestination(Waypoint destination)
Sets a single destination for navigation, overriding any previously set destinations.
|
abstract ListenableResultFuture<Navigator.RouteStatus> |
setDestinations(List<Waypoint> destinations, RoutingOptions options)
Sets multiple destinations for navigation, overriding any previously set destinations.
|
abstract ListenableResultFuture<Navigator.RouteStatus> |
setDestinations(List<Waypoint> destinations, RoutingOptions routingOptions, DisplayOptions displayOptions)
Sets multiple destinations for navigation, overriding any previously set destinations.
|
abstract ListenableResultFuture<Navigator.RouteStatus> |
setDestinations(List<Waypoint> destinations)
Sets multiple destinations for navigation, overriding any previously set destinations.
|
abstract void |
setHeadsUpNotificationEnabled(boolean enabled)
Sets whether heads-up notifications should be shown.
|
abstract void |
setLicensePlateRestrictionInfo(int rawLicensePlateLastDigit, String licensePlateCountryCode)
Sets license plate information about the current driver.
|
abstract void |
setRemainingTimeOrDistanceChangedListener(int timeChangeThresholdSeconds, int distanceChangeThresholdMeters, Navigator.RemainingTimeOrDistanceChangedListener listener)
Registers a listener for when the remaining time or distance to the destination changes by more
than a specified threshold.
|
abstract void |
setRouteChangedListener(Navigator.RouteChangedListener listener)
Registers a listener for route changed events.
|
abstract void |
setSpeedingListener(SpeedingListener speedingListener)
Registers a
SpeedingListener for the percentage above the speed limit the driver is
currently driving at. |
abstract void |
startGuidance(Intent resumeIntent)
The same as
startGuidance() , but specifying an intent that can be used to resume the
application from the navigator's status bar notification. |
abstract void |
startGuidance()
If a destination has been set and a route computed for it, starts turn-by-turn navigation
guidance for the route.
|
abstract void |
stopGuidance()
Stops turn-by-turn navigation guidance.
|
Public Methods
public abstract void cleanup ()
Cleans up internal state of the Navigator.
Note: calling this method will cancel any pending requests to setDestinations(List
.
public abstract void clearDestinations ()
Clears all previously set destinations and removes any calculated routes from the map. If navigation is running, this will automatically stop it.
public abstract void clearLicensePlateRestrictionInfo ()
Clears license plate information about the current driver. This will only apply to setDestination calls made after this value is set.
public abstract void clearRemainingTimeOrDistanceChangedListener ()
Clears the listener for changes in remaining time or distance.
public abstract Waypoint continueToNextDestination ()
Removes the current destination. Following this call, guidance will be toward the next destination, and information about the old destination is not available.
Returns
- the waypoint guidance is now heading to, or null if there were no more waypoints left
public abstract ListenableResultFuture<RouteInfo> fetchRouteInfo (Waypoint waypoint, RoutingOptions routingOptions)
Returns route information for routes based on each value of RoutingOptions.RoutingStrategy
. RoutingOptions.RoutingStrategy
is ignored since this method returns the route information for all routing
strategies.
Note: This is recalculated on every call and may not match the routes currently being used by navigation since traffic and other factors may have been updated in the interim.
Parameters
waypoint | the destination waypoint for the route |
---|---|
routingOptions | the options used to fetch the route info |
Returns
- the returned future
public abstract RouteSegment getCurrentRouteSegment ()
Returns the current leg of the journey. This RouteSegment will have its starting position as the most recent known (road-snapped) position of the device.
Returns
- a route segment object, or
null
if there is no current route
public abstract TimeAndDistance getCurrentTimeAndDistance ()
Returns the estimated time and distance from the current position to the current destination.
Returns
- a time and distance object, or
null
if there is no current route
public abstract List<RouteSegment> getRouteSegments ()
Returns a list of route segments. The destination of each returned segment will correspond to a destination set by setDestination(s).
public abstract List<TimeAndDistance> getTimeAndDistanceList ()
Returns a list of times and distances corresponding to each destination in the current route, representing the estimated time and distance from the current position to each destination.
public abstract List<LatLng> getTraveledRoute ()
Returns the route traveled so far during this guidance session (since the last call to startGuidance()
). The route recorded consists of the road-snapped locations as would be
returned by the RoadSnappedLocationProvider
, and simplified to remove redundant points,
for example turning consecutive colinear points into a single line segment.
public abstract boolean isGuidanceRunning ()
Returns true
if guidance is currently running. Note that guidance will only run once a
route to a destination has been computed and startGuidance()
has been called.
public abstract void setArrivalListener (Navigator.ArrivalListener listener)
Registers a listener for arrival events. Overrides any previously registered listeners.
Note: In order to avoid memory leaks, setNavArrivalListener(null)
should be called
when the listener is no longer required.
Parameters
listener | the listener to register. Can be set to null to clear a previously
registered listener.
|
---|
public abstract void setAudioGuidance (int guidance)
Sets which types of audio guidance (including vibration) are enabled. By default, vibration, voice, and voice over Bluetooth (if available) are enabled.
This method must be called on the UI thread.
Parameters
guidance | a combination of Navigator.AudioGuidance flags specifying which types of audio
guidance should be enabled
|
---|
public abstract ListenableResultFuture<Navigator.RouteStatus> setDestination (Waypoint destination, RoutingOptions routingOptions, DisplayOptions displayOptions)
Sets a single destination for navigation, overriding any previously set destinations. The
returned future will be set to OK
if a route is found from the user's
location to the given destination.
Parameters
destination | the new destination to be set |
---|---|
routingOptions | the options that will be used to generate the route |
displayOptions | the options that will be used to display the route |
Returns
- the returned future
Throws
NullPointerException | if the given destination is null |
---|
public abstract ListenableResultFuture<Navigator.RouteStatus> setDestination (Waypoint destination, RoutingOptions options)
Sets a single destination for navigation, overriding any previously set destinations. The
returned future will be set to OK
if a route is found from the user's
location to the given destination. The default DisplayOptions
will be used to display
the route.
Parameters
destination | the new destination to be set |
---|---|
options | the options that will be used to generate the route |
Returns
- the returned future
Throws
NullPointerException | if the given destination is null |
---|
public abstract ListenableResultFuture<Navigator.RouteStatus> setDestination (Waypoint destination)
Sets a single destination for navigation, overriding any previously set destinations. The
returned future will be set to OK
if a route is found from the user's
location to the given destination. The default RoutingOptions
will be used to find the
route, and the default DisplayOptions
will be used to display it.
Parameters
destination | the new destination to be set |
---|
Returns
- the returned future
Throws
NullPointerException | if the given destination is null |
---|
public abstract ListenableResultFuture<Navigator.RouteStatus> setDestinations (List<Waypoint> destinations, RoutingOptions options)
Sets multiple destinations for navigation, overriding any previously set destinations. The
returned future will be set to OK
if a route is found from the user's
location to the given destination. The default DisplayOptions
will be used to display
the route.
Parameters
destinations | the new destination list to be set |
---|---|
options | the options that will be used to generate the route |
Returns
- the returned future
public abstract ListenableResultFuture<Navigator.RouteStatus> setDestinations (List<Waypoint> destinations, RoutingOptions routingOptions, DisplayOptions displayOptions)
Sets multiple destinations for navigation, overriding any previously set destinations. The
returned future will be set to OK
if a route is found from the user's
location to the given destination.
Parameters
destinations | the new destination list to be set |
---|---|
routingOptions | the options that will be used to generate the route |
displayOptions | the options that will be used to display the route |
Returns
- the returned future
public abstract ListenableResultFuture<Navigator.RouteStatus> setDestinations (List<Waypoint> destinations)
Sets multiple destinations for navigation, overriding any previously set destinations. The
returned future will be set to OK
if a route is found from the user's
location to the given destination. The default RoutingOptions
will be used to find the
route, and the default DisplayOptions
will be used to display it.
Parameters
destinations | the new destination list to be set |
---|
Returns
- the returned future
public abstract void setHeadsUpNotificationEnabled (boolean enabled)
Sets whether heads-up notifications should be shown. By default, the notification is enabled. Heads-up events are guidance events such as turns, etc, that are displayed when there is no map visible.
This method must be called on the UI thread.
Parameters
enabled | a flag to indicate if heads-up notifications should be enabled |
---|
public abstract void setLicensePlateRestrictionInfo (int rawLicensePlateLastDigit, String licensePlateCountryCode)
Sets license plate information about the current driver. This allows us to route around certain types of road restrictions which are based on license plate number. This will only apply to setDestination calls made after this value is set. Ideally you'd call this immediately after getting the navigator.
Parameters
rawLicensePlateLastDigit | The last digit of the license plate (must be between 0 and 9). |
---|---|
licensePlateCountryCode | Currently we support Indonesia (ID) and Brazil (BZ) others may be supported in the future and you are free to proactively provide this information. |
public abstract void setRemainingTimeOrDistanceChangedListener (int timeChangeThresholdSeconds, int distanceChangeThresholdMeters, Navigator.RemainingTimeOrDistanceChangedListener listener)
Registers a listener for when the remaining time or distance to the destination changes by more than a specified threshold. Overrides any previously registered listeners.
The listener could be called as a result of (for example) user movement, a change in traffic conditions, a change in route, a change in destination, or when the remaining time and distance first become known.
Note: In order to avoid memory leaks, clearNavProgressionListener()
should be called
when the listener is no longer required.
Parameters
timeChangeThresholdSeconds | If the absolute change in the remaining time in seconds is greater than or equal to this value, then the listener is called. This threshold must not be negative. |
---|---|
distanceChangeThresholdMeters | If the absolute change in the remaining distance in meters is greater than or equal to this value, then the listener is called. This threshold must not be negative. |
listener | the listener to register. Must not be null .
|
public abstract void setRouteChangedListener (Navigator.RouteChangedListener listener)
Registers a listener for route changed events. Overrides any previously registered listeners.
Note: In order to avoid memory leaks, setNavRouteChangeListener(null)
should be
called when the listener is no longer required.
Parameters
listener | the listener to register. Can be set to null to clear a previously
registered listener.
|
---|
public abstract void setSpeedingListener (SpeedingListener speedingListener)
Registers a SpeedingListener
for the percentage above the speed limit the driver is
currently driving at.
By setting a null
SpeedingListener
or not setting any, you won't receive any
speeding feed data.
Parameters
speedingListener |
---|
public abstract void startGuidance (Intent resumeIntent)
The same as startGuidance()
, but specifying an intent that can be used to resume the
application from the navigator's status bar notification. Without this intent it is not
possible to resume the application from the status bar.
Parameters
resumeIntent | the intent for resuming the application. In most cases the value returned
by android.app.Activity#getIntent() will be suitable.
|
---|
public abstract void startGuidance ()
If a destination has been set and a route computed for it, starts turn-by-turn navigation guidance for the route. If a route has not yet been computed, turn-by-turn guidance will start once it has.
You must explicitly call stopGuidance() to stop the navigation service. The navigation service will not automatically stop upon arrival. If you want to stop the navigation service upon arrival, you need to call stopGuidance() in the NavArrivalListener.
Note: this method does not change the position of the Camera
.
public abstract void stopGuidance ()
Stops turn-by-turn navigation guidance.