I have a binder service which binds at onResume. At onResume I want to check if the previous onPause was called because of app minimised or screen was lock by lock button. I have tried with ACTION_SCREEN_ON and ACTION_SCREEN_OFF and setting a boolean value, but the problem is my binder at onResume get called before receiver gets the value.
Asked
Active
Viewed 119 times
0
-
Add your code what you tried – Muthukrishnan Rajendran Aug 15 '17 at 05:10
1 Answers
0
use below code
to detect whether screen
is locked in onPause()
method
KeyguardManager km= (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( km.inKeyguardRestrictedInputMode()) {
//Screen is locked
} else {
//it is not
}

Rajan Kali
- 12,627
- 3
- 25
- 37