Problem:
Sometimes is necesary to detect if the screen phone is locked or not. There is a couple of ways to detect that but the best way is the following...
Solution:
Implement the following method and check if return true (locked) or false (unlocked)
Context context = getApplicationContext();
KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
if( myKM.inKeyguardRestrictedInputMode()) {
//it is locked
} else {
//it is not locked
}
No hay comentarios:
Publicar un comentario