Skip to content Skip to sidebar Skip to footer

Doze Mode, Battery Optimization Whitelist, Alarmmanager More Frequent Than 9 Mins

I'm creating an app to connect with BT device to collect heath data (i.e.: body temperature). The sensor sleeps for periodic time and wakes up only for limited window of time to c

Solution 1:

What are the regular alarms ? is setExactAndAllowWhileIdle() regular ?

No. setExactAndAllowWhileIdle() is not regular. Regular alarm could be AlarmManager alarms set though setExact() and setWindow().

but below 9 minutes it goes to doze mode and do not fire AlarmManager BroadcastReceiver

It has restrictions on how frequently you can set alarm.

Based on the documentation:

To reduce abuse, there are restrictions on how frequently these alarms will go off for a particular application. Under normal system operation, it will not dispatch these alarms more than about every minute (at which point every such pending alarm is dispatched); when in low-power idle modes this duration may be significantly longer, such as 15 minutes.

You can refer to Doze restrictions which says:

Standard AlarmManager alarms (including setExact() and setWindow()) are deferred to the next maintenance window.

  • If you need to set alarms that fire while in Doze, use setAndAllowWhileIdle() or setExactAndAllowWhileIdle().
  • Alarms set with setAlarmClock() continue to fire normally — the system exits Doze shortly before those alarms fire

For Whitelist:

Apps available in whitelist are partially exempt from Doze and App Standby optimizations. This doesn't mean they have full access to and could perform tasks during doze mode. An app that is whitelisted can use the network and hold partial wake locks during Doze and App Standby. However, other restrictions like jobs being differed, standard alarm trigger are still imposed

Note: You should check acceptable usecases for whitelisting an app.

Google Play policies prohibit apps from requesting direct exemption from Power Management features in Android 6.0+ (Doze and App Standby) unless the core function of the app is adversely affected.

Post a Comment for "Doze Mode, Battery Optimization Whitelist, Alarmmanager More Frequent Than 9 Mins"