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();