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

Exposing return value of onStartCommand() of NavigationNotificationService

Open moritzzzzz opened this issue 3 years ago • 0 comments

We are experiencing a problem with NavigationNotificationService when the user revokes location permissions.

The NavigationNotificationService is stopped because the user revokes the location permissions while the SDK is running. Then, after I try to use the app again (after the service has restarted) it sometimes crashes because of the service already running

The NavigationNotificationService is restarting itself after it's killed by the system. I've noticed that's because you're using the START_STICKY flag for the service. I know that this flag is useful in some cases but in our scenario it is causing us some trouble

Would it be an option to expose the return value of onStartCommand()? Or would it be an option to allow the service to restart only if required permissions are given?

Please also see:

https://github.com/mapbox/mapbox-navigation-android/blob/main/libnavigation-core/src/main/java/com/mapbox/navigation/core/trip/service/NavigationNotificationService.kt#L38

**Android API:**30 Mapbox Navigation SDK version: latest

Steps to trigger behavior

  1. Run navigation app that uses the Mapbox Nav SDK
  2. Revoke location permissions
  3. Use the app with revoked permissions

Expected behavior

Service should not restart if the location permissions are insufficient.

Actual behavior

NavigationNotificationService restarts automatically, independent of missing permissions.

moritzzzzz avatar Nov 16 '21 16:11 moritzzzzz