Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Doze State

Tags:

Is it possible to detect when a device enters Doze/Standby? I haven't been able to find anything in the Android documentation about a possible Broadcast Receiver or Listener that I could enable or create in order to receive notifications of these transitions.

like image 670
Kevassi Avatar asked Feb 02 '16 00:02

Kevassi


1 Answers

I believe the Intent you're looking for is ACTION_DEVICE_IDLE_MODE_CHANGED. From the documentation:

Intent that is broadcast when the state of isDeviceIdleMode() changes. This broadcast is only sent to registered receivers.

The documentation for isDeviceIdlemode is as follows:

Returns true if the device is currently in idle mode. This happens when a device has been sitting unused and unmoving for a sufficiently long period of time, so that it decides to go into a lower power-use state. This may involve things like turning off network access to apps. You can monitor for changes to this state with ACTION_DEVICE_IDLE_MODE_CHANGED.

Returns

Returns true if currently in active device idle mode, else false. This is when idle mode restrictions are being actively applied; it will return false if the device is in a long-term idle mode but currently running a maintenance window where restrictions have been lifted.

like image 142
stkent Avatar answered Oct 12 '22 21:10

stkent