android 点亮手机屏幕与屏幕解锁方法


点亮手机屏幕

1.记得加权限android:name="android.permission.WAKE_LOCK">

PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
PowerManager.WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.FULL_WAKE_LOCK, "WakeLock");
mWakelock.acquire();//唤醒屏幕
//......
mWakelock.release();//释放

屏幕解锁
1.记得加权限
//获取一个键盘锁对象
KeyguardManager mManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
KeyguardLock mKeyguardLock = mManager.newKeyguardLock("Lock");
//让键盘锁失效
mKeyguardLock.disableKeyguard();

你可能感兴趣的:(android 点亮手机屏幕与屏幕解锁方法)