So, I'm using version Mapbox Navigation 0.3.1
, I'm fetching route from private OSRM server. Snap-to-route
and other features are just working fine, however when 1st step finishes navigation wouldn't proceed to the next step and offRoute
method is being called. I'm stuck here for like 1-2 months. I would appreciate any help.
Below, my code snippet of Mapbox Navigation implementation.
public class MapActivity implements MapboxMap.OnMarkerClickListener
,OnMapReadyCallback, AlertLevelChangeListener, ProgressChangeListener, OffRouteListener
,NavigationEventListener, LocationEngineListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fabStartNavigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// star Navigation
startNavigation();
}
});
}
@Override
protected void onDestroy() {
super.onDestroy();
// Remove all navigation listeners being used
mNavigation.removeNavigationEventListener(this);
mNavigation.removeAlertLevelChangeListener(this);
mNavigation.removeProgressChangeListener(this);
mNavigation.removeOffRouteListener(this);
// End the navigation session
mNavigation.endNavigation();
mapView.onDestroy();
}
//navigation controller
private void startNavigation(){
mNavigation.addNavigationEventListener(this);
mNavigation.addAlertLevelChangeListener(this);
mNavigation.addOffRouteListener(this);
mNavigation.addProgressChangeListener(this);
mNavigation.setSnapToRoute(true);
/*LocationEngine mLocationEngine = LostLocationEngine.getLocationEngine(this);
// mNavigation.setLocationEngine(mLocationEngine);*/
mLocationEngine = LostLocationEngine.getLocationEngine(this);
mLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
mLocationEngine.addLocationEngineListener(this);
mLocationEngine.activate();
mNavigation.startNavigation(mPlannedRoute);
}
// navigation listeners
@Override
public void onAlertLevelChange(int alertLevel, RouteProgress routeProgress) {
switch (alertLevel) {
case HIGH_ALERT_LEVEL:
break;
case MEDIUM_ALERT_LEVEL:
break;
case LOW_ALERT_LEVEL:
break;
case ARRIVE_ALERT_LEVEL:
break;
case NONE_ALERT_LEVEL:
break;
case DEPART_ALERT_LEVEL:
break;
}
}
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
}
@Override
public void userOffRoute(Location location) {
}
@Override
public void onRunning(boolean running) {
}
@Override
public void onConnected() {
mNavigation.setLocationEngine(mLocationEngine);
mLocationEngine.requestLocationUpdates();
}
@Override
public void onLocationChanged(Location location) {
}
}
This sounds like your running into a really old bug that has since been fixed. My advice would be to either upgrade to 0.4.0 or the 0.5.0-snapshot.