android 自动亮屏解锁,android锁屏唤醒并解锁屏幕

1、这个方法是实现锁屏状态下唤醒手机,亮屏并解锁屏幕:public static void wakeUpAndUnlock(Context context){

//屏锁管理器

KeyguardManager km= (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);

KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");

//解锁

kl.disableKeyguard();

//获取电源管理器对象

PowerManager pm=(PowerManager) context.getSystemService(Context.POWER_SERVICE);

//获取PowerManager.WakeLock对象,后面的参数|表示同时传入两个值,最后的是LogCat里用的Tag

PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK,"bright");

//点亮屏幕

wl.acquire();

//释放

wl.release();

}

加入权限:

2、这个收集的://锁屏、唤醒相关

private KeyguardManager km;

private KeyguardLock kl;

private PowerManager pm;

private PowerManager.WakeLo

你可能感兴趣的:(android,自动亮屏解锁)