androidandroid-alertdialogkeyguard

IntentService and locked screen


I need to show some information in the Dialog or something same via IntentService. This dialog should be shown at the locked screen and wake up the phone if it has been locked. If it's possible and how can I do something like in WhatsApp application when message incoming?


Solution

  • This is only possible if the device is not locked by a password. This may also require device admin permissions.

    The following code will unlock the device and allow you to display whatever you wish.

    KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Service.KEYGUARD_SERVICE);
        KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
        lock.disableKeyguard();