1

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?

JussT
  • 181
  • 1
  • 4
  • 15

2 Answers2

1

I'm pretty sure the user has to manually remove widgets from the home screen. Here is a reference

nandeesh
  • 24,740
  • 6
  • 69
  • 79
Kevin Qiu
  • 1,616
  • 1
  • 13
  • 15
0

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 :-(

Community
  • 1
  • 1
David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • it won't. The code will, definitely, but your launcher may still hold 'zombie widget' unless you remove it manually. – Marcin Orlowski Aug 16 '12 at 19:11
  • So there is no way I can write some code to remove it when the application gets removed? – JussT Aug 17 '12 at 12:06
  • Oops. I was sure this worked, but I just tried it and unfortunately it doesn't work. So, no. You are in the same boat as all other app developers: When you app is uninsalled, your widget stays on the screen and says "problem loading..." (or whatever). Welcome to the club. – David Wasser Aug 17 '12 at 12:35
  • @WebnetMobile.com You are sooo right and I am sooo wrong :-( I edited my answer and beg forgiveness. – David Wasser Aug 17 '12 at 12:36