3

Currently using powerManager.isIgnoringBatteryOptimizations(getPackageName()) for devices running api >= 23.

And requesting user to allow my app to be not optimised by using

Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + getPackageName()));

This works on most of the devices, but on Oneplus devices even after user allowing it to be not optimised, I see no effect, my application is still optimised and I miss SMS_RECEIVED broadcast.

Oneplus device with Oxygen OS 5.0.1 and Android OS 8.0.0

Aalap
  • 2,847
  • 2
  • 26
  • 24
  • This is the song of my people! I can confirm that the OnePlus 3T does the same - both before and after the upgrade to Android 9, and despite the user explicitly confirming that the app may run without battery optimisations. – instantiator Jun 28 '19 at 21:30
  • 1
    you may use this context.startActivity(new Intent( Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)); you have to allow your not to be OPTIMIZED from the setting Activity. – karan Dec 03 '21 at 14:10

0 Answers0