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.
Related
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
I know that it's not possible to place an app widget programatically on the homescreen - the user has to do it by himself. But is there a way, to let the user create an app widget without having to go to the "widgets-tab" and choosing it from the list of all available widgets?
My idea is to have a Button in my Activity, which provides some kind of shortcut to that list . This way the user still would create it by himself, but he wouldn't have to leave the app. Is there an Intent I could use in combination with startActivityForResult()?
Have a look at CommonsWare answer here:
Add widget to homescreen from Android application
You can bring the list up put you are unable to select a widget and install it for that your app must be an appWidgetHost
In Android O, its possible to pin app widget programmatically. Just watch at example here
Also check out Google official documentation
I want to capture event when an user try to go into the preferences screen, so I can ask password for it. The reason why I try this, I am developing app for the disabled. I don't want them to touch system settings directly, just the permitted helper.
Is there any event listener or receiver for this?
Thanks in advance.
I don't think there is anything in the public APIs that will allow you to do this. Device Admin is probably the closest thing, but I don't think it does this exactly.
If you wish to implement this (and be certain that it will be effective) you'd have to modify the OS slightly on your devices.
One possibility that might work and is within the APIs is to create a replacement home screen that does not show the usual items in the menu. If you were to go this route you could "lock" the into your activity and simply provide them no way to go to the settings except with a password or something. This would be a lot of work though, and would require the user to set your application as their default home screen. And even with this on the newer devices you may run into the trouble because there is a settings button inside the notification pull down, which I don't think there is a way to block, even with a replacement homescreen.
I was doing an android app and I want to lock some feature temporally for each user.
What I want is to lock say 1 activity to be used before someone performs a predefined task say share on facebook, only then I want them to view the activity.
How can I achieve this? It is for application, just like games lock the level.
You should make an application/user profile and save it in a database or in the shared preferences.
you could simply check if a certain task has been performed prior to opening the activity you want locked.
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?