0

For a good execution of my app it would be needed that the mentioned battery optimization were permanently disabled.

I already know how to ask for the permission and enable it, but problem is that the user is able to disable it later by himself or maybe some other way. If this happens then I cannot longer guarantee that services from my app are going to execute when they should (specially on API 28). I could warn the user about this, that if he disables the permission for the app undesired things may happen, so he knows it's his fault.

But maybe there's some way to ask for this permission on some installation window on the app and keep it for as long as the app is installed without being able to change it, no matter how hard this is tried.

Is there any possible way to do what I'm mentioning?

mylket
  • 147
  • 7

1 Answers1

0

By design, user should be able to manage his permissions at any given moment, especially ones that are as risky as ignoring battery optimizations.

Please also remember, that requesting REQUEST_IGNORE_BATTERY_OPTIMIZATIONS might result in your app being banned from the Play Store, so it'd be safer to use ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS Intent. (refer to https://developer.android.com/training/monitoring-device-state/doze-standby#support_for_other_use_cases)

In summary, what you're requesting is not possible and for a good reason - an evil ]:-> developer might make the phone practically unusable by having this permission permanently added to his app.

r2rek
  • 2,083
  • 13
  • 16