Unlock phone programatically in Angular


Is there a way to programatically unlock the phone? Or at least to display a screen similar to an alarm clock ? I’ve tried setting the flags as bellow, on my unlock event, but it doesn’t seem to work.

let activity = app.android.startActivity;
| android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON


The flags you are using are just for keeping the screen on while Activity is alive. When exactly you want to unlock the phone, upon a notification or timer?


Currently I’m using a timer


It’s not guaranteed that your Activity may be alive for ever once it’s paused based on system settings. You should run a background service if you want to do something in background Or AlarmManager if that suits your requirement.

Use Wakelock to unlock phone.