1. The Android screen is always on/lit
//Keep the screen on
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = (PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, LOCK_TAG);
();
//Release the screen to always turn on the lock
if(null != mWakeLock) {
();
}
2. Android screen unlocking and locking
//Screen unlock
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
KeyguardLock keyguardLock = (LOCK_TAG);
();
//Screen lock
();
3. Related permissions
<uses-permission android:name=".DISABLE_KEYGUARD" />
<uses-permission android:name=".WAKE_LOCK" />
Copy the codeThe code is as follows:
//Keep the screen on
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = (PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, LOCK_TAG);
();
Copy the codeThe code is as follows:
//Release the screen to always turn on the lock
if(null != mWakeLock) {
();
}
2. Android screen unlocking and locking
Copy the codeThe code is as follows:
//Screen unlock
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);
KeyguardLock keyguardLock = (LOCK_TAG);
();
//Screen lock
();
3. Related permissions
Copy the codeThe code is as follows:
<uses-permission android:name=".DISABLE_KEYGUARD" />
<uses-permission android:name=".WAKE_LOCK" />