android disables lock screensaver holding constant bright of sample code
- 2020-05-19 05:47:46
- OfStack
When video is playing, mediaplayer
mMediaPlayer. setScreenOnWhilePlaying (true); It has been set up, there is no problem with native android and no problem with defy, there is a problem with 1 to 3 star galaxy, I don't know what 3 star they changed. Type 1 words set to play video screen not automatically. But it was a problem on three. I'll have to try again. There are two ways to set the standard.
As follows:
1. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
2.
onResume enable
wakeLock = ((PowerManager) getSystemService(POWER_SERVICE))
.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
| PowerManager.ON_AFTER_RELEASE, TAG);
wakeLock.acquire();
onPause disable
if (wakeLock != null) {
wakeLock.release();
}
Neither of these methods works in galaxy.
The third method:
mContentResolver = getContentResolver();
setLockPatternEnabled(false);
public void setLockPatternEnabled(boolean enabled) {
setBoolean(android.provider.Settings.System.LOCK_PATTERN_ENABLED,
enabled);
}
private void setBoolean(String systemSettingKey, boolean enabled) {
android.provider.Settings.System.putInt(mContentResolver,
systemSettingKey, enabled ? 1 : 0);
}
permissions <uses-permission android:name="android.permission.WRITE_SETTINGS" />
This will disable the lock screen.