mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

NavigationView does not reroute if phone screen is off

Open jeffwasher opened this issue 8 years ago • 8 comments

Navigation works when the phone screen is off, so I assume this is an intended use case. However if the User goes off route while the screen is off, no reroute action happens. Since NavigationViewModel.offRouteEvent and NavigationViewModel.isOffRoute are MutableLiveData, the reroute action won't fire and my RouteListener doesn't receive a call to onOffRoute.

jeffwasher avatar Mar 12 '18 15:03 jeffwasher

Hey @jeffwasher, what version of the SDK are you using? Also, can you post the code you're using to set up the off-route listener you're talking about here? Thanks!

danesfeder avatar Mar 12 '18 15:03 danesfeder

Hi @danesfeder, I'm using mapbox-android-navigation-ui:0.11.0

Here's where I set the RouteListener (I've got an Activity holding a NavigationView):

@Override
    public void onNavigationReady() {
        final NavigationViewOptions.Builder options = NavigationViewOptions.builder();
        final MapboxNavigationOptions.Builder navigationOptions = MapboxNavigationOptions.builder();
        switch (preferredDistanceUnit) {
            case KM:
                navigationOptions.unitType(NavigationUnitType.TYPE_METRIC);
                break;
            case MILES:
                navigationOptions.unitType(NavigationUnitType.TYPE_IMPERIAL);
                break;
        }
        options.navigationOptions(navigationOptions.build());
        options.navigationListener(this);
        options.routeListener(this);
        DirectionsRoute route = extractRoute(this);
        if (route == null) {
            reportError(ERROR_ROUTE_NULL);
            return;
        }
        options.directionsRoute(route);
        final Intent intent = getIntent();
        options.shouldSimulateRoute(intent.getBooleanExtra(EXTRA_SHOULD_SIMULATE, false));
        options.progressChangeListener(progressChangeListener);
        options.milestoneEventListener(milestoneEventListener);
        navigationView.startNavigation(options.build());
        presenter.onNavigationStarted();
    }

Let me know if you need more. Thanks

jeffwasher avatar Mar 12 '18 15:03 jeffwasher

@jeffwasher you're only seeing this issue when the app is in the background?

danesfeder avatar Mar 12 '18 16:03 danesfeder

That's correct. The screen is off. The voice instructions continue to work until you go off route. Then silence.

jeffwasher avatar Mar 12 '18 17:03 jeffwasher

@devotaaabel now that https://github.com/mapbox/mapbox-navigation-android/pull/751 has landed 🎉 could you try to reproduce 👇 https://github.com/mapbox/mapbox-navigation-android/issues/750#issuecomment-372389883

The voice instructions continue to work until you go off route. Then silence.

and 👀 if the issue is still present?

Guardiola31337 avatar Apr 06 '18 16:04 Guardiola31337

@Guardiola31337 I have the same issue and I'm trying to implement this with 0.13.0-SNAPSHOT, but now I'm not getting any voice instructions :( Do I have to change something to get voice in 0.13?

chooble avatar Apr 17 '18 14:04 chooble

In 0.13 the reroute events are still not fired when the app is in background.

chooble avatar Apr 18 '18 09:04 chooble

cc @akitchen

devotaaabel avatar Apr 19 '18 15:04 devotaaabel