I’d like to disable/delay
the lock screen programmatically. In looking into this, KeyguardManager
is depreciated/doesn\'t work consistently,
try this, it will keep awake the screen/ display , as long as the activity is on top.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Also this does not require any permission in manifest.
Did you try this?
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
Add
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
You can disable the keyguard using this.
the answer of @nandeesh is working but it's deprecated , to disable lock screen use flags :
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);