Faster-route detection

SDKs covered:
Navigation SDK
Navigation UI SDK

The Navigation SDK includes a faster-route detection class. This class checks each location update as well as the progress along the current route to determine if a new route should be retrieved.

Fetching faster routes is disabled by default in the Navigation SDK. To enable either the default logic or your own custom logic, you can create a MapboxNavigationOptions object and set MapboxNavigationOptions#enableFasterRouteDetection(boolean); to true. MapboxNavigationOptions is then passed into the constructor of MapboxNavigation.

Faster-route detection and the Navigation UI SDK

This guide does not describe any specific options in the Navigation UI SDK. You need to enable faster-route detection using the core Navigation SDK directly.

Default faster-route detection

After enabling faster-route detection, the default logic in FasterRouteDetector checks for a faster DirectionsRoute every two minutes, only if both of the following conditions are true:

  • The current route duration remaining is more than 600 seconds
  • The current step duration remaining is more than 70 seconds

When a new DirectionsRoute is retrieved, it is considered faster if all the following conditions are true:

  • The upcoming step is the same as the current upcoming step
  • The first step of the new route is more than 70 seconds in duration
  • It is at least 10 percent faster than the duration remaining of the current route


You are able to listen to the retrieval of a faster DirectionsRoute with FasterRouteListener. This listener will fire if a new route is retrieved and meets the given criteria of FasterRoute#isFasterRoute.

navigation.addFasterRouteListener(new FasterRouteListener() {
public void fasterRouteFound(DirectionsRoute directionsRoute) {
// Update MapboxNavigation here

Custom logic for fetching faster routes

If you would like to provide your own logic to replace the default logic above, you can do so by subclassing FasterRoute and passing your class to MapboxNavigation with MapboxNavigation#setFasterRouteEngine(FasterRoute).

When to check for a faster route

FasterRoute#shouldCheckFasterRoute(Location, RouteProgress) will determine when a new DirectionsResponse should be retrieved by the RouteEngine. This method will be called every time the Navigation SDK gets a Location update from the LocationEngine.

What qualifies as a faster route

FasterRoute#isFasterRoute(DirectionsResponse, RouteProgress) will be used to determine if the route retrieved is faster than the one that's being navigated. This method will be called every time a response is received from the RouteEngine.

Was this page helpful?