0

我想在我的应用程序中接收短信时点亮屏幕。我应该怎么办?是否也可以解锁屏幕?谢谢!

4

1 回答 1

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();

并在清单中添加权限

< uses-permission android:name="android.permission.WAKE_LOCK" />
于 2014-01-03T04:17:02.863 回答