My app uses location permission. If this permission is revoked at runtime from App Settings and coming back to app, the current activity is destroyed and recreated. How to prevent the recreation of that activity?
You can't. If the user revokes a permission from your app, Android terminates your process. This forces you to go back through your check-for-the-permission code, where you will find out that you lost the permission.
Since your app's process can be terminated at any point when your UI is not in the foreground, your app should already be able to handle this case. If it cannot, then you need to fix that, as your process will be terminated for other reasons while it is in the background (OS freeing up system RAM, user using a task-killer app, user pressing Force Stop in Settings, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With