有个项目客户需要开休眠锁屏功能, 在产测程序测试重启测试时, 锁屏界面挡住了测试界面, 需要处理.
import android.app.KeyguardManager;
import android.os.PowerManager;
Log.d(TAG, "wakeup");
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.SCREEN_DIM_WAKE_LOCK, "StartupReceiver");
wl.acquire();
Log.d(TAG, "disableKeyguard");
KeyguardManager km= (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
KeyguardManager.KeyguardLock kl = km.newKeyguardLock("StartupReceiver");
kl.disableKeyguard();
参考:
android开机自动唤醒屏幕、打开锁屏页并启动app
来源:CSDN
作者:季风
链接:https://blog.csdn.net/dc3120/article/details/103960026