4

Would it be possible to keep an android device in a locked state while having something displayed on the screen? Meaning all functionality would work as if the device is locked (since it would be locked) and the only difference would be that there is something displayed on the screen. The main purpose of this question is to display something just as the notification bar does in a locked state and to be able to return to the original lock screen instead of having something be displayed on the device and once the lock screen is pressed it blanks out the device and you must press it again to return to the locked interface.

jaiesh
  • 146
  • 2
  • 12
  • And your users will need to charge their phones every 2 hours? – Dalmas Nov 17 '11 at 15:54
  • haha I guess if you decide to display something extravagant, however a lot of apps that do display things such as notifications seem to leave the locked state and do so. Do you think displaying something as simple as a digital clock would eat up the battery as much? – jaiesh Nov 17 '11 at 18:41
  • jalesh, please accept an answer or explain why the given answers are insufficient for you. – activout.se Aug 28 '12 at 16:59

3 Answers3

3

Add this line to your activity. The window will be shown even when screen is locked, as simple as that.

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

Cheers..........!!!!!!!!!

Rohit
  • 593
  • 2
  • 8
  • This solution worked for me on ICS. It will allow you to display an activity that you can back out of to get to the lock screen. – Epsilon Prime Jan 04 '12 at 17:17
1

You can sort of do this. There are some customization tools and how-to's on this front, but from a development standpoint you want to take a look at the comments from CommonsWare in this question.

There is some open source code available that has some stuff you can review on how other folks have done it, but sounds like the Android team is moving away from enhancing this functionality.

Update: Your question also piqued my interest further on this front, so I've been browsing the Google groups on this topic and some others. This is an interesting but older read that has some background on this as well.

Community
  • 1
  • 1
Mat Nadrofsky
  • 8,289
  • 8
  • 49
  • 73
0

You can learn how it can be done if you look into the open source project contact owner that adds a message to the lock screen

"if you find this phone please call +49 ..."

Android 4.2 introduces the ability for users to add widgets to the lock screen.

k3b
  • 14,517
  • 7
  • 53
  • 85