我希望在我的应用中接收短信时点亮屏幕。我该怎么办?是否有可能解锁屏幕? 谢谢!
答案 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" />