MichiBros
MichiBros

Reputation: 142

Correct way to ask to disable battery optimizations

I'm currently developing an app that transfers files via wi-fi under the same network. The transfer jobs are done by WorkManager and all operations are marked as high priority (they are converted to foreground services, if possible and priority quota has not been exceeded). However, the transfer will stop if the device goes into doze mode (screen is shut off). To prevent this from happening, I should ask the user to whitelist the app from battery optimizations. I have three options:

  1. Ask directly using ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: while this is the most direct and user-friendly way to get the job done, it goes against the Play Store policies, so I'd rather not use this if possible.

  2. Redirect to settings and guide the user to whitelisting the app using ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS: this should be the correct way to achieve this according to the documentation. However, on some devices (Oppo A5 2020, Android 10/ColorOS 7 to be specific) the list shown contains only already exempted apps, with no way to switch to all apps, unlike other devices).

  3. Redirect to the app's details page in settings and tell the user to tap on Battery > Disable optimizations. While this is also an user friendly way, I found it pretty inconsistent on Android <= 10 (on some devices tapping on Battery does nothing, but on the aftermentioned Oppo device it seems the only way to actually disable optimizations for an app).

Is there some way around this? Or do I have to check for the device manufacturer and use different methods from device to device?

Upvotes: 3

Views: 606

Answers (0)

Related Questions