I have a widget and I want to auto-update it on one occasion only and that is when the user unlocks his phone. This is a requirement I have and it is not negotiable.
So how do I do that? How can I make sure that I get any callback of any kind when the user unlocks the screen. The update of the widget does not need to be instant. It is enough if it updates a couple of seconds after the screen is unlocked.
Is this possible?
Thanks
Did you try to use https://developer.android.com/reference/android/content/Intent#ACTION_USER_PRESENT
You can try to use BroadcastReceiver that listens for this event and then update your widget
Related
I want to control my android smartphone that after my son playing games on my phone after a specified time such as half an hour, the phone will be locked unless you submit the right password.
I don't know how to trigger the lock screen process.
How can I implement interrupting the games processes and lock the cellphone?
How unlock and lock screen programatically in android Has some excellent information on immediately calling the lock screen. You could implement a system using an alarm manager to trigger this event.
Here is a good example,
first thing you need to do this, U need to know when the screen gets unlock. So here you go.....
android-detect-phone-unlock-event-screen-on
After that you set a time for 30/40/50 minutes (as you wish).
Once the timer fires, use below link to lock your screen.
lock-phone-screen-programmtically
And your work is done.
The default longclick event of the widget enables the user to delete it. Is it possible to lock the widget so the user couldn't delete it? I would certainly build in an if condition to the let the user decide when they want to delete the widget.
Is it possible to lock the widget so the user couldn't delete it?
There is no API for this, sorry.
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.
Is there an Event that is fired when an widget becomes visible on to the homescreen. I didn't mean at install time, I mean if the user changes his homescreen by wiping the surface of the phone.
The background of this question is that I setup a timer in a service inside the widget that gets updates from a url but that should stop if the widget is not on the current homescreen.
Freudi
There is a way to do that, you can listen to Intent.ACTION_USER_PRESENT broadcast and update your widget on receiving the intent.
It will be fired when the user unlocks the home screen.
I am using it in my app and works great to update your widgets upon unlock.
No, sorry. There are dozens of home screen applications, some of whom may not even have the concept of "wiping the surface of the phone". A home screen is merely an activity with a particular <intent-filter>.
Not sure if this helps, but I stumbled across this..
WallpaperManager.setWallpaperOffsets() and WallpaperService.onOffsetChanged()
Perhaps you could use this? Set wallpaper offsets and use onOffsetChanged() to get current offsets?