0

My app needs to remove the lock screen of Android devices. It is done as mentioned here and it works.

When does the lock screen come back? For example suppose I write those lines of code in my main activity and the user starts my app, until when the lock screen will not appear?

Community
  • 1
  • 1
Soheil
  • 1
  • 3

1 Answers1

0

Until a call to the reenableKeyguard() method of your KeyguardLock object.

KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard(); //keyguard disabled
//some code
lock.reenableKeyguard(); //keyguard reenabled

(Also I suppose a restart would re-enable it too. ;])

See: http://developer.android.com/reference/android/app/KeyguardManager.KeyguardLock.html#disableKeyguard()

AlienHoboken
  • 2,750
  • 20
  • 23