点亮屏幕

            if(!pm.isScreenOn()) {//在点亮屏幕的前提下,activity的onNewIntent才会被执行
                PowerManager.WakeLock locker = pm.newWakeLock(
                              PowerManager.ACQUIRE_CAUSES_WAKEUP
                            | PowerManager.FULL_WAKE_LOCK, "phone_keyguard");
                int timeout = Settings.System.getInt(getContentResolver(),
                            Settings.System.SCREEN_OFF_TIMEOUT, 120*1000);//默认2分钟
                locker.acquire(timeout);//点亮屏幕并在timeout时间后关闭屏幕
                //locker.isHeld()
            }

//点亮屏幕和关闭屏幕跟屏幕解锁没有直接关系(甚至根本没有关系)

//----------------------
        // Turn on the screen
        if (!getIntent().getBooleanExtra(SCREEN_OFF, false)) {
            win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
                    | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
        }

你可能感兴趣的:(屏幕)