强制Android手机睡觉,为了测试? [英] Force an android phone to sleep, in order to test?
问题描述
我正在写一个Android应用程序依赖于网络活动和报警经理有时醒来的手机从休眠状态。
I'm writing an android application that depends on network activity and the alarm manager sometimes waking the phone up from a sleeping state.
我的问题是我怎么能可靠地对设备进行测试呢?理想情况下,我怎么能强迫手机变成一个完整的睡眠状态。如果做不到这一点,我怎么能肯定知道手机已经完全进入睡眠状态时?
My question is how can I reliably test this on device? Ideally, how can I force the phone into a full-on sleeping state. Failing that, how can I know for sure when the phone has fully gone to sleep?
你怎么测试您的报警管理/唤醒锁定/休眠处理code?
How do you test your Alarm Manager / Wake Lock / Sleep handling code?
推荐答案
pressing设备上的电源按钮应该把它睡觉。还有一个 goToSleep(时间长)方法在 PowerManager的,但需要的 DEVICE_POWER 权限,这是保留给系统应用。
Pressing the power button on the device should put it to sleep. There is also a goToSleep(long time) method in the PowerManager, but that requires DEVICE_POWER permission, which is reserved for system applications.
这篇关于强制Android手机睡觉,为了测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!