I am looking for a way to replace the stock lock screen (with an app, not a rom). What is the best way to do it, for a start to disable the lock screen on as much devices as possible? Thanks!
Asked
Active
Viewed 3.8k times
4 Answers
40
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
in androidmanifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

PravinDodia
- 3,271
- 1
- 18
- 22

Mitul Nakum
- 5,514
- 5
- 35
- 41
-
6The class KeyguardLock has been deprecated. Setting the window flags as shown by @hsgubert below seems the current way to turn off the key guard/lock screen. – pstoppani Feb 01 '13 at 00:48
-
1
34
You can just use this line in the activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

hsgubert
- 2,266
- 1
- 22
- 23
6
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.

Swapnil Kale
- 2,620
- 2
- 23
- 21
-
1Instead of writing same answer, you could have upvoted the answer by @hsgubert – CopsOnRoad Aug 01 '17 at 14:46
-
1@CopsOnRoad. Solution seems to be different than that is provided by hsgubert. Is it something I am missing here ? – Swapnil Kale Mar 13 '18 at 21:11
2
Check out this link http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
listen to the screen on intent and I guess just launch your lock screen.

Faisal Abid
- 8,900
- 14
- 59
- 91