Android Lock Screen Widget

Several users ask me about the Android screen widgets for my application - I believe that they need a widget that remains on the lock screens and allows them to interact with the application.

I could not find the official documentation for this - the only thing I found was applications that will display widgets on the main screen and put them on the lock screen for you.

Any tips on where I will learn more about creating real lock screen widgets?

+66
android android-widget lockscreen
Nov 07 2018-10-10T00:
source share
3 answers

Blocking screen interaction is difficult. Android allows you to perform basic operations using two window flags (FLAG_SHOW_WHEN_LOCKED and FLAG_DISMISS_KEYGUARD). FLAG_SHOW_WHEN_LOCKED works quite consistently, because it will be displayed on top of the lock screen even when security is turned on (security is not bypassed, you cannot switch to a different window than FLAG_SHOW_WHEN_LOCKED).

If you just do something temporary, like when music is playing or something like that, you will probably be mostly fine. If you are trying to create a custom lock screen, then there are a lot of unusual interactions on all different Android platforms. ("Help! I cannot turn off the alarm without restarting my HTC phone.").

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); 

http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html

 FLAG_SHOW_WHEN_LOCKED 

Window flag: a special flag so that windows are displayed when the screen is locked.

 FLAG_DISMISS_KEYGUARD 

Window flag: if you install a window, this will cause the keyguard to be rejected only if it is not safe to lock the keypad. Because such a key lock is not required for security. never appear if the user moves to another window (unlike FLAG_SHOW_WHEN_LOCKED, which will temporarily hide both safe and unprotected keyboard locks, but appear when the user switches to another user interface that does not hide them). If a key lock is currently active (an unlock pattern is required) than the user will still need to confirm this before viewing this window if FLAG_SHOW_WHEN_LOCKED has also been set. Constant value: 4194304 (0x00400000)

+51
Jan 12 2018-11-12T00:
source share

Document widgets official lock window here

+26
Nov 16 '12 at 1:12
source share

I had to implement a screen lock widget for my project. In this process, I have accumulated several resources.

  • If you have an application that you want to put on the lock screen, first make it appwidget . You can use the AppWidget class for AppWidget .
  • Now, using the AppWidgetHost class from the Android API up , make your locked screen host for widgets. I do not know how to do this, but there are some existing implementations, such as mylockandroid (links below).



Resources

http://code.google.com/p/mylockforandroid/ (NB This code is for older versions of Android. Android 4.2 and higher have built-in support for screenshot widgets)

http://mylockandroid.blogspot.com/2010/03/widget-lockscreen-beta-11-r2.html

+9
Mar 22 '11 at 3:00
source share



All Articles