android:接收短信时点亮屏幕(并解锁)

时间:2012-11-29 15:55:47

标签: android

我希望在我的应用中接收短信时点亮屏幕。我该怎么办?是否有可能解锁屏幕? 谢谢!

1 个答案:

答案 0 :(得分:2)

使用PowerManager唤醒屏幕

PowerManager pm = (PowerManager)   getApplicationContext().getSystemService(Context.POWER_SERVICE);
        WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
        wakeLock.acquire();

并在Manifest中添加权限

< uses-permission android:name="android.permission.WAKE_LOCK" />