Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android screen lock/ unlock programmatically [duplicate]

Tags:

I am working on a app in which I have to lock and unlock the screen programmatically. Kindly help ! I have no any idea how to develop this type of functionality which support each version of Android OS.

like image 687
Amit Avatar asked Oct 04 '12 08:10

Amit


People also ask

How do I unlock my screen lock if I forgot the pattern?

After you've tried to unlock your phone multiple times, you'll see "Forgot pattern." Tap Forgot pattern. Enter the Google Account username and password you previously added to your phone. Reset your screen lock. Learn how to set a screen lock.

Can you break a pattern lock on Android?

Bypass Samsung Pattern Lock with ResettingIn Android Recovery Mode, you are able to bypass pattern lock by resetting your phone with physical buttons.


1 Answers

To Unlock

KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);  final KeyguardManager.KeyguardLock kl = km .newKeyguardLock("MyKeyguardLock");  kl.disableKeyguard();   PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);  WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK                                  | PowerManager.ACQUIRE_CAUSES_WAKEUP                                  | PowerManager.ON_AFTER_RELEASE, "MyWakeLock"); wakeLock.acquire(); 
like image 87
Viraj Tank Avatar answered Oct 15 '22 00:10

Viraj Tank