Removing Widget from Home Screen when Uninstalled - android

When my application is uninstalled, a widget that is contained in this packages stays on the HOME
screen and gives an error message "problem loading widget".
How do I remove the widget when my application is uninstalled? Is there an
attribute in the manifest that I am missing?
I thought this thing should be handled by the OS, but guess it is not.
EDITED: I am now catching the "PACKAGE_ REMOVED" intent, and checking the "EXTRA_REPLACING" to make sure it's not a reinstall, but I don't know the actual code to use to actually remove the widget.

You cannot add or remove app widgets from the home screen. Only the user can do that.
Quoting #CommonsWare #4532121

Related

Home Screen Listener?

I want to detect if the user has manually added or remove a shortcut of my application in the home screen.
I tried to use broadcast receivers for the actions below:
com.android.launcher.permission.UNINSTALL_SHORTCUT
com.android.launcher.permission.INSTALL_SHORTCUT
But they are not triggered when I manually adding or removing a shortcut of my application to and from my homescreen.
I wonder if there are listeners for this?
I searched on Android Developer site and didn't find any information about this.
So for anyone who encounter this issue.
I tried to solve this with different approaches as described below:
To use broadcast receivers for the actions com.android.launcher.permission.UNINSTALL_SHORTCUT com.android.launcher.permission.INSTALL_SHORTCUT
but as I said before, they were not triggered and I couldn't listened for the home screen in order to detect if the user has manually added or removed a shortcut.
Moreover, #CommonsWare comment is correct :)
I tried to check inside my application, using ShortcutManager or PackageManager and see if the application shortcut already exists on the Home Screen, but as you can guess, there was no way to find it...
So... bottom line -> it is not possible

Android Appwidget not showing in launcher after installation

Q. Android Appwidget not showing in launcher immediately after installation:-
What I have already tried and does not work consistently
Included stub Activity with MAIN and LAUNCHER intent filter
Included this code in onCreate() of this stub activity
sendBroadcast(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
What works consistently
Reboot
Change orientation of device with widget list opened. This causes a refresh of the widget list and shows the newly installed widget.
So is there something I am missing ? It creates poor perception when user installs widget and does not find the widget in the widget list. Generally leads to uninstall :(
This is an open issue for some devices and OS versions (mainly ICS it seems). What are you running? It should be the same issue which is, hopefully, soon fixed. I think the best option for you would be to inform your customers about this bug and that it is out of your hands. You should then also provide an easy way to fix it! An informed customer is less likely to have false expectations and uninstall your widget.

Android remove widget on app uninstall

I have a problem with a widget I have for an application.
If I put the widget on my homescreen, then I uninstall the application that my widget comes from, but the widget will not be removed on the homescreen. Instead of the widget there is a text saying: : "Loading".
Are there some kind of code I need to write so it gets removed when I uninstall the application on the phone?
I'm pretty sure the user has to manually remove widgets from the home screen. Here is a reference
You should package your widget and your app in the same APK. Then, when you uninstall the app, the widget will automagically get removed.
EDIT Unfortunately, I should have tested this before I posted. This does NOT work. You cannot programmatically remove the widget when the app is uninstalled. see this and this. 1000 Apologies for my incorrect advice :-(

Android app Widget update new version removes the existing widget

I developed an APP + Home screen widget for Android. Now I updated the app (incremented the version code/name) but when i install, it doesn't automatically replaces the existing widget on screen. It just says "problem loading widget".
Any Idea??
Did you change the class name of the broadcast receiver implementing your widget? If so, don't do that.
There is of course the related use-case where there was a widget loaded on the home page and the user then uninstalls the application that contains the widget and widget config app. I guess this is the same as a new version which must to an uninstall/install cycle.
When that happens, all you see is the "Problem Loading Widget" in a toast-like box on the home screen. As far as I can tell, the widget gets no indicatation that the package is being uninstalled and I guess then the home screen AppWidgetManager thows up a default message.
Not well thought out behaviour on the part of the OS team. I suggest that it would be better to call the widget's onDisbled() and onDestroy() methods and to remove the widgets from the home screen before the package is removed so they can tidy up if need be and the user (non-geek phone user) gets a clean experience.
All I can find is the indication that only the user can remove a widget from the home screen, says commonsguy: Removing AppWidgets programmatically
I sure us developers can handle the odd weird toast, but for non technical "ordinary" phone users this sort of behaviour drives them back to iPhones very quickly.
This is the right behavior to me. As app is installed again, its widgets should be installed again too. If, for instance, there is a new activity to configure the widget, how do you know it as a user ?
There is, indeed, no way to guarantee that a new widget would run at all from this perspective.

Remote service clean up, launcher screen refresh required

the problem is that once a widget of my application is uninstalled, it lkeaves a black message box on the home screen saying unable to load widget, i was wonderring if we could clean the system display our self, is it possbile to add some code/ call to instruct the android frame work to do that, the widget is being consumed by a remote service may be once service is finished/closed we can call some syetem calls, any code for helping out the home reloading will help, Thanks
There is nothing for you to do. The user and the home screen will take care of this.

Categories

Resources