Change permissions in the application

It’s hard for me to figure out how to properly handle a resolution-changing user while my application is still running in the background.

In my application, I have a location class that registers location changes and when the location changes status it is sent to the server. However, this works in the background.

When my application is running, I test it with the user, if I use it to use location services, and if so, I continue to configure this class. However, the user can use my application and enter the settings and delete this permission. I can and will definitely check if it is allowed in my location class before requesting a location from the location service to avoid a crash. However, I don’t do business when the place comes, so I’m not sure how to tell them that my application needs location services.

EDIT:

It seems that android is restarting your application if permission has been revoked in the settings. However, I confirmed that at the moment, the android does not restart your application if permission was granted using the settings.

+6
source share
3 answers

I read somewhere that your application gets killed when a user changes permissions on Android-M, so you can be sure that this will not change while your application is running. He will be killed when this changes.

Check out this video as a reference: https://www.youtube.com/watch?v=f17qe9vZ8RM

+4
source

However, I don’t do business when the place comes, so I’m not sure how to tell them that my application needs location services.

Raise Notification by warning the user that your application cannot complete its intended work without permission, which they revoked. Associate Notification with Activity using PendingIntent , where the user can grant this permission.

+1
source

Along with the CommonsWare proposal, you can onProviderDisabled () find out which provider (gps, network) is disabled and, accordingly, requestLocationUpdate () for the one that is still enabled. If both are disabled, see if at least the location of the cell is suitable for your application. If so, you can send the location of the cell at least until the user sees a notification and enables permission. Use PhoneStateListener to do this.

0
source

All Articles