检测打ze状态 [英] Detecting Doze State

查看:60
本文介绍了检测打ze状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检测设备何时进入打ze/待机状态?在Android文档中,我找不到能够启用或创建的可能的广播接收器或侦听器的任何功能,以便接收这些过渡的通知.

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.

推荐答案

我相信您要查找的Intent

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

isDeviceIdleMode()的状态更改时广播的意图.此广播仅发送给注册的接收者.

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

isDeviceIdlemode 的文档与如下:

The documentation for isDeviceIdlemode is as follows:

如果设备当前处于空闲模式,则返回true.当设备闲置闲置并移动了足够长的时间,从而决定进入低功耗状态时,就会发生这种情况.这可能涉及关闭对应用程序的网络访问之类的事情.您可以使用ACTION_DEVICE_IDLE_MODE_CHANGED监视此状态的更改.

返回

如果当前处于活动设备空闲模式,则返回true,否则返回false.这是主动应用空闲模式限制的时候.如果设备处于长期空闲模式但当前正在运行已解除限制的维护窗口,则它将返回false.

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.

这篇关于检测打ze状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆