Detecting Doze State

前端 未结 1 1745
天涯浪人
天涯浪人 2020-12-15 05:41

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 Listene

相关标签:
1条回答
  • 2020-12-15 06:33

    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.

    0 讨论(0)
提交回复
热议问题