Android 亮屏及屏幕解锁代码

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>


PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.SCREEN_DIM_WAKE_LOCK, "SimpleTimer");
mWakelock.acquire();
mWakelock.release();

 
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
keyguardLock.disableKeyguard();
使用这两段代码,需要在AndroidManifest文件中加入:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>