How to find out if the phone is locked

Guys, do I have a way to find out if the phone is in a locked state?

+3
source share
1 answer

Ask the app to listen to our feed ACTION_SCREEN_OFF. More info here .

public class ScreenReceiver extends BroadcastReceiver {     

        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
                //screen locked                
            } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
                //screen unlocked   
            }
        }

}

You might also want to get information about when a user passed the key lock by registering for ACTION_USER_PRESENT .

+1
source

All Articles