views:

213

answers:

3

My app has a 1*4 icon size widget. When a user tries to add a widget I provide with a configuration screen. and some data is collected - it is verified by the server - it is added to the local DB with appWidgetID as the key - all is good.

when user hits save, if there is not enough space, he is given a polite toast - "No more room on this home screen".

Now my problem is that the application is not informed of this. Application still assumes the widget was created and sits back and wait for the broadcast to update the widget after certain amount of time.

Can anyone tell me if i can find out via a broadcast or a call back or any method possible to determine if the widget was not successfully created, so that i can mark that record in my DB as deleted.

Or better if i can know the space available beforehand via some magic ninja code.

my whole application design is disturbed because of this problem. please help.

A: 

Have you checked to see if onDeleted() in your AppWidgetProvider gets called in this case? I haven't tried it, but I would hope that would work.

If that doesn't get called, you can try onDisabled(), though that will only work if there is no other copy of your app widget on the home screen at the time.

CommonsWare
A: 

I believe this is currently a bug in the OS where the onDeleted() method never gets called if there isn't enough room for the widget on the screen. I know I've seen this at least up through Android version 1.5. There is no fix that I'm aware of.

mbaird
+1  A: 

This has been fixed in either 1.6 or 2.0.

Romain Guy
Ah, I wasn't aware that a fix was out. I still try to code to SDK level 3 to support the biggest audience, which explains why I'm still seeing it.
mbaird