Hello! I am writing an application that detects screen unlocking on a device. As soon as the screen is unlocked - the application sends a signal to the server. So, how can I detect unlock the screen?

    1 answer 1

    Found a solution.

    public class PhoneUnlockedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { KeyguardManager keyguardManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE); if (keyguardManager.isKeyguardSecure()) { //экран разблочен, логика здесь } } } 

    Then add it to the activation:

     registerReceiver(new PhoneUnlockedReceiver(), new IntentFilter("android.intent.action.USER_PRESENT"));