问题描述
我想禁用/延迟
锁屏编程。在寻找到这一点, KeyguardManager
是德preciated /不工作始终, FLAG_DISMISS_KEYGUARD
是不是一种选择因为我想这样做的背景下,我不希望使用WakeLock电池的原因,设备管理似乎并不具有如此,虽然 SCREEN_OFF_TIMEOUT
是可用于控制的时候,屏幕睡觉,我无法找到一个类似的超时锁屏。
I’d like to disable/delay
the lock screen programmatically. In looking into this, KeyguardManager
is depreciated/doesn't work consistently, FLAG_DISMISS_KEYGUARD
is not an option because I want to do this in the background, I don't want to use WakeLock for battery reasons, Device Administration does not appear to be capable of this and, while SCREEN_OFF_TIMEOUT
is available to control when the screen sleeps, I was unable to find a similar timeout for the screen lock.
我在想什么吗?谢谢你。
What am I missing here? Thanks.
推荐答案
试试这个,它会保持清醒的屏幕/显示,只要在活动之上。 getWindow()addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
try this, it will keep awake the screen/ display , as long as the activity is on top. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
另外,这并不需要在清单的许可。
Also this does not require any permission in manifest.
这篇关于禁用/延迟的Android锁屏编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!