Reputation: 9594
On most phones PowerManager.isIgnoringBatteryOptimizations()
is working correctly but on a few phones the value is always false
even when the user has manually selected allow background usage
or don't optimize
under battery settings for the app.
I suspect this means my package name has entered some list on those phones due to excessive battery usage or due to not being used much. I was able to get one of those phones to whitelist my app again running adb -d shell dumpsys deviceidle whitelist +packagename
but that isn't an acceptable solution for users.
So, what are my options? Can users at least look at whatever might have put the app on that list? Can they change that somehow without using adb
? The two devices I'm testing are Android 14.
Upvotes: 1
Views: 127
Reputation: 9594
So I was wrong, this doesn't just apply to some phones, this seems to be a thing on all Android 14+ phones, or if not all, at least all Pixels. But I figured out the issue.
Allow background usage
doesn't mean anything as far as isIgnoringBatteryOptimizations
is concerned. You have to press on Allow background usage
to open another screen and then select unrestricted
.
Upvotes: 0