Disable Lock Screen

前端 未结 4 1003
耶瑟儿~
耶瑟儿~ 2020-12-02 17:31

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

相关标签:
4条回答
  • 2020-12-02 17:53

    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.

    0 讨论(0)
  • 2020-12-02 18:12

    You can just use this line in the activity:

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    
    0 讨论(0)
  • 2020-12-02 18:12

    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.

    0 讨论(0)
  • 2020-12-02 18:13
    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"/>
    
    0 讨论(0)
提交回复
热议问题