android 点亮屏幕与解锁

下面的代码可以用来点亮屏幕
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.SCREEN_DIM_WAKE_LOCK, "SimpleTimer");
mWakelock.acquire();. w- K8 u# h: b- g5 L0 Q
.......8 o4 I7 D( A$ y3 a) |
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>

posted @ 2011-06-15 14:49  Gang.Wang  阅读(4916)  评论(1编辑  收藏  举报