Open Battery Optimization activity of specific app in device settings
Asked Answered
G

0

6

I am using WorkManager library to schedule a background task, and to prevent the app from sleeping the battery optimization section is opened from the app for the users to manually disable optimization for my app. The problem is even though the 'Don't optimize' option is selected the app still sleeps and the work is not done. Also when opening battery settings through the app info page in device settings it shows 'Optimized' even though it was changed to 'Don't optimize' in the previous activity.

Also, the battery optimization page opened through code has a list of all the apps including system apps, while the one opened through app info contains only a list of installed apps.

Is there any way to get to the second battery optimization page through code. Because if optimization is disabled there app is working fine.

Intent intent = new Intent();
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
startActivity(intent);
finish();
Guerdon answered 18/6, 2019 at 4:37 Comment(5)
You don't need to disable battery optimizations for Work Manager.Vitebsk
But for me, it only works when battery optimization is disabled for my appGuerdon
Then you should file a bug with a sample project that reproduces your issue and what device you're using since it is working without battery optimizations on many thousands of other apps.Vitebsk
It would probably work on Pixel devices but what about all other Chinese ROMs. Infact I am facing this issue on OnePlus's Oxygen OS.Guerdon
Facing the same issue, did you find a solution? :) @NoyalOrsay

© 2022 - 2024 — McMap. All rights reserved.