2

I searched internet and got 2 codes to unlock android phone programmatically. But none of them I see,use passwords. 1>

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();

2>

WindowManager wm = Context.getSystemService(Context.WINDOW_SERVICE);   

//Unlock
Window window = getWindow();  
window.addFlags(wm.LayoutParams.FLAG_DISMISS_KEYGUARD);  

//Lock device  
DevicePolicyManager mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);

I tried them but could not unlock the password protected screen

chinpin
  • 39
  • 4
  • I'm also not yet found solution in other many similar questions. Need to try to examine source code of Android - to see what API called on corresponding UI. If you need to unlock device programatically to get 'Boot Completed' event as work around by now I can suggest to disable stock lock screen and to install one of lock screen applications. But with them now there is security problem - https://stackoverflow.com/q/74294993/1455694 – Anton Samokat Nov 02 '22 at 21:23
  • Related question: [Unlock android mobile with PIN code programmatically Selenium mobile automation](https://stackoverflow.com/q/40145397/1455694) – Anton Samokat Nov 06 '22 at 21:34

0 Answers0