安卓:删除或禁用三星Galaxy S2设备上编程的锁屏 [英] Android: remove or disable programmatically the Lock Screen on Samsung Galaxy S2 device
问题描述
问题我的Android自动化测试是不可靠的,因为测试活动有时运行,有时会暂停。
The problem My Android automated tests are unreliable, because the tested activities are sometimes running and are sometimes paused.
的原因如果我的Android设备(三星Galaxy S2)有锁屏,所有的活动都立即进入暂停模式。
The cause If my android device (a Samsung Galaxy S2) has its Lock Screen on, all activities are immediately put in Pause mode.
如何以编程方式禁用锁定屏幕,而我的测试运行?
How can I programmatically disable the Lock Screen while my tests are running?
下面是我的尝试和产生没有结果在所有(即锁屏依然活跃,并暂停我的活动)。
Here is what I tried and that produced no result at all (i.e., Lock Screen still active and pausing my activities).
-
添加
android.permission.DISABLE_KEYGUARD
许可并使用KeyguardLock.disableKeyguard()
在解释在机器人DOC 。
Add the
android.permission.DISABLE_KEYGUARD
permission and useKeyguardLock.disableKeyguard()
as explained in the android doc.
设置窗口标志:FLAG_SHOW_WHEN_LOCKED,FLAG_TURN_SCREEN_ON,FLAG_DISMISS_KEYGUARD
Set Window flags: FLAG_SHOW_WHEN_LOCKED, FLAG_TURN_SCREEN_ON, FLAG_DISMISS_KEYGUARD.
使用 WakeLock.acquire()
与 PowerManager.FULL_WAKE_LOCK
,电源管理器.ACQUIRE_CAUSES_WAKEUP
, PowerManager.ON_AFTER_RELEASE
和 PowerManager.SCREEN_BRIGHT_WAKE_LOCK
参数。
亚行外壳输入的KeyEvent 82
推荐答案
我真希望这是不可能删除/禁用锁屏编程。这将使没用。
I really hope that it is not possible to remove/disable the lock-screen programmatically. That would make it useless.
为什么你不能简单地关闭锁屏设备上手动,运行测试之前?
Why do you not simply disable the lock-screen on your device manually, before running your tests?
这篇关于安卓:删除或禁用三星Galaxy S2设备上编程的锁屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!