Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KeyguardManager - requestDismissKeyguard() method alternative for api 25 and below [Android]

I was recently trying to request user to dismiss key-guard manually from my app. My app invokes a activity screen when device is locked and the screen has the flags

FLAG_SHOW_WHEN_LOCKED
FLAG_TURN_SCREEN_ON

When I have to invoke another screen which does not have these flags I want to request the user to unlock the key-guard, this behaviour can be seen in the the camera app - when we want to share a photo taken while phone is locked it will request us to unlock the device.

requestDismissKeyguard() method works only for api26 and above any alternatives for the lower apis ??

like image 847
Shangeeth Sivan Avatar asked May 24 '18 11:05

Shangeeth Sivan


1 Answers

you can use flags for lower versions

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
                WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
like image 94
BÜNYAMİN YETİM Avatar answered Jan 02 '23 09:01

BÜNYAMİN YETİM