My customer want a screen-saver for android, I use the
KeyguardManager
Intent.ACTION_SCREEN_OFF
Ref: http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
When the Intent.ACTION_SCREEN_OFF received, my activity really started. but the screen is off, so I can not see nothing, What I really want is the sreen-saver UI will show on screen.
Is there a way to control the screen on/off programmtically?
You should see Coding for (Battery) Life Google IO presentation, slide 16 for keeping screen on
see if this helps
http://www.androidsnippets.com/stop-screen-from-dimming-by-enforcing-wake-lock
Related
I would like to know if it is possible to let the screen turn off (as setted in device parameters) but to prevent the phone to lock while my application is running in front.
So, when something happen in the app, I can turn on the screen and the user dont have to unlock his phone. (It is a driving application, so it would be dangerous to make the user unlock the phone while driving)
Thanks!
EDIT:
I dont want the screen to stay on : I want to be able to turn it on and when I do, that I dont have to unlock the screen.
Use this in your activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| +WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
I hope it will help. This will prevent your app to lock while your activity is visible.
There are many ways to do this.. One of the way is to set this flag in your activities oncreate.
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
For the other ways to keep your screen on.. Link.
I have created a Lock screen and i want to show the notifications of messages,missed call etc on the lock screen for example if i received 2 messages and 3 missed calls then it should display on lock screen.
Anyone please tell me how i can do this?
you can use App Widgets which can also be displayed in the lock screens (maybe not all types).
Consider the android:widgetCategory="home_screen|keyguard" property.
See these
App Widgets
you can make use of flag FLAG_SHOW_WHEN_LOCKED
and This great example by google.
Hope this helps.
I'm writing a Kiosk app that, along with having some UI elements, also has a service that sits around in the background while the user explores other features on the device, and wish to re-launch the UI portion of the kiosk when the user has walked away. I figured that the most reliable way to do this is to listen for the screen to go dim and react to that event. However, I'm not seeing anything in the documentation about a system wide broadcast that I can listen to that the screen state has changed. Curious if I'm just overlooking it, or if it doesn't exist.
Take a look at this answer:
android.intent.action.SCREEN_OFF
FYI there is a full list of broadcast intents available in your sdk/platforms/android-xx/data/broadcast_actions.txt if you want to have a look. I found these two quickly, which led me to the answer I linked:
android.intent.action.SCREEN_OFF
android.intent.action.SCREEN_ON
Hii all,
Im developing an emergency calling application. What i want is when some person uses this specific code the phone will unlock and then only my application would be running. Im juz thinking i need a reciever for it and just wondering wether i will have to create my own Home screen and a lock screen for my application. any ideas on this please???
many thanks in advance :)
There's some caveats in just doing SCREEN_OFF and USER_PRESENT
1) Phone isn't locked right after screen off if the screen timed out by itself, there's a few second delay
2) If screen goes off for other reasons (phone call) it might not be locked at all.
3) You'd have to be monitoring them the whole time, if you're started when the phone is locked you wouldn't know
You can use the KeyguardManager http://developer.android.com/reference/android/app/KeyguardManager.html and check inKeyguardRestrictedInputMode()
Another option would be to use the PowerManager http://developer.android.com/reference/android/os/PowerManager.html and check isScreenOn() if you actually just care about screen state and not keyguard state.
You can create a BroadcastReceiver and register it with your application to listen for Intent.ACTION_SCREEN_OFF, Intent.ACTION_SCREEN_ON, and Intent.ACTION_USER_PRESENT. Between SCREEN_OFF and USER_PRESENT, the phone is locked.
There is no sanctioned way to replace the lock screen. See Is there a way to override the lock pattern screen?
The previous answer was to another question that got merged with this one:
I would look into ACTION_NEW_OUTGOING_CALL, and also at this Android Developers blog post about receiver priority.
Hii all,
Im developing an emergency calling application. What i want is when some person uses this specific code the phone will unlock and then only my application would be running. Im juz thinking i need a reciever for it and just wondering wether i will have to create my own Home screen and a lock screen for my application. any ideas on this please???
many thanks in advance :)
There's some caveats in just doing SCREEN_OFF and USER_PRESENT
1) Phone isn't locked right after screen off if the screen timed out by itself, there's a few second delay
2) If screen goes off for other reasons (phone call) it might not be locked at all.
3) You'd have to be monitoring them the whole time, if you're started when the phone is locked you wouldn't know
You can use the KeyguardManager http://developer.android.com/reference/android/app/KeyguardManager.html and check inKeyguardRestrictedInputMode()
Another option would be to use the PowerManager http://developer.android.com/reference/android/os/PowerManager.html and check isScreenOn() if you actually just care about screen state and not keyguard state.
You can create a BroadcastReceiver and register it with your application to listen for Intent.ACTION_SCREEN_OFF, Intent.ACTION_SCREEN_ON, and Intent.ACTION_USER_PRESENT. Between SCREEN_OFF and USER_PRESENT, the phone is locked.
There is no sanctioned way to replace the lock screen. See Is there a way to override the lock pattern screen?
The previous answer was to another question that got merged with this one:
I would look into ACTION_NEW_OUTGOING_CALL, and also at this Android Developers blog post about receiver priority.