How to remove a widget when the application is uninstalled on Android?

Possible duplicate:
Removing a widget from the main screen when uninstalling

In Android, I created a widget for my application. When I uninstall the application, the widget shows the error "loading download failed" on the main screen. I need a scenario where the widget needs to be removed by the developer using the code (and not by dragging and dropping to the trash) when the application is deleted. Is it possible? If so, what changes do we need to make? Is there anything that can be set in the manifest to remove all application links after it is deleted?

+7
android widget uninstall
source share
2 answers

Hiya! When you uninstall the application widget, the host manager must broadcast one of the following intentions ... ACTION_APPWIDGET_UPDATE ACTION_APPWIDGET_DELETED ACTION_APPWIDGET_ENABLED ACTION_APPWIDGET_DISABLED

To use this, in your application provider class (or custom extension of the broadcast receiver), you can receive the broadcast (or use onDeleted () in the appwidgetprovider class) and remove the widget with the identifier of your widget from the application widget host manager ....

Hope this helps ...

-one
source share

There is no way to gain control when your application is uninstalled. I think Android 2.2 can do better with automatically getting rid of the widget of your application.

+5
source share

All Articles