0

Can we show any widget on the lock screen as per the latest android sdk? or How we can draw a layout on lockscreen?

Reference Application: https://play.google.com/store/apps/details?id=app.medicalid.free

This application show icon on lock screen and show another activity on tapping the icon without unlocking the device.

How we can achieve this functionality?

  • This question isn't very clear. A quick look at that page suggests to me that they're creating their own "lock screen" to show a widget, or just using a notification. The second image shows something that is not the standard Android lock screen. – Ryan M May 23 '20 at 10:49
  • I need to show the application Icon or any layout on lockscreen. On tapping this icon I need to show another layout with four options without unlocking the device. How I can achieve this? – yogesh sharma May 25 '20 at 04:44

1 Answers1

0

i install your example app and if you want show activity on lock screen you can use this code:

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
        {
            setShowWhenLocked(true);
            setTurnScreenOn(true);
            KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
            if(keyguardManager!=null)
                keyguardManager.requestDismissKeyguard(this, null);
        }
        else
        {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
        }
Taher Fattahi
  • 951
  • 1
  • 6
  • 14