How to remove widget when the app is uninstalled in Android?

Showing 1-2 of 2 messages
How to remove widget when the app is uninstalled in Android? angel999 8/10/11 8:14 PM
In Android, I have created a widget for my application. When I
uninstall the app, the widget shows "problem loading widget" error in
home screen. I need a scenario where widget should be removed by the
developer through code (and not by the drag and drop to the trash)
when I uninstall the app. Is it possible? If so, what changes we need
to do? Is there anything that can be set in the manifest so that it
removes all references of the app once it is uninstalled? Please help
me solve this problem. Thanks.
Re: How to remove widget when the app is uninstalled in Android? david ross 9/1/11 10:43 PM
This is a design bug as far as I am concerned. There seems to be
nothing you can do about it except let the poor phone user drag the
toast to the trash can. I think you can listen for an Intent
PACKAGE_UNINSTALL and then check to see if it is actually a reinstall
for a new version, but there is no way to programatically remove the
widget from the home screen.

A related problem use-case is when the user does the CLEAR DATA
option. This seems to be like an uninstall without actually removing
the APK. The intention is that it is like taking the App back to the
"just installed" state, but if the App is actually an active home
screen widget then it just causes chaos. The widget remains, but any
shared preferences and any registered receivers are removed. I call
that a "ghost widget". At least the user can drag it to the trash can.

(Ghost Widgets occur also from things like a power off/on cycle when
the widget config app is running and in pre 2.1 OS if the user tries
to install the widget on a home screen with not enough space to fit
the widget. Some ghosts are in the eye of the OS (it thinks the widget
exists but it doesn't), others are in the eye of the App, but in all
cases there is no functioning widget.)

On Aug 11, 11:14 am, angel999 <lehuy...@gmail.com> wrote:
> In Android, I have created awidgetfor my application. When I
> uninstall the app, thewidgetshows "problemloadingwidget" error in
> home screen. I need a scenario wherewidgetshould be removed by the