Android 通知屏幕亮起

添加权限:<uses-permission android:name="android.permission.WAKE_LOCK" />

/**
 * 唤醒屏幕
 *
 * @param context
 */
@SuppressLint("InvalidWakeLockTag")
private void wakeUpScreen(Context context) {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (!pm.isInteractive()) {
        PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");
        wl.acquire(10 * 1000); // 点亮屏幕
        wl.release(); // 释放
    }
}

 

你可能感兴趣的