Hello,

I am in the process of updating my widget to allow appearance configuration. There is a config activity, and a few preference values, organized by widget id.

My widgets are updated outside onUpdate in response to Wi-Fi events, and the code need to apply individual configuration to each widget.

To get widget ids, I do this:

ComponentName thisWidget = new ComponentName(context, WifiWidget.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
int[] appWidgetIds = manager.getAppWidgetIds(thisWidget);

For some reason getAppWidgetIds returns many more values than there are widgets. I have just one widget on the home screen, and appWidgetIds has eight (8) values.

I suspect the other 7 values are old, no longer active, instances of the same widget. Since my code has no way to tell active from inactive widgets (this is what getAppWidgetIds is supposed to do!), it means my code builds and marshalls eight times as many updates as possible. I guess there is also a threat of ANRs because of this.

This is Moto Milestone with Android 2.1.

Am I correct about the source of these incorrect widget IDs? Any suggestions for a workaround?

Instead of allowing the user to configure a widget, I could create parallel versions of the same widget, so the user would pick the desired variation from the installed widgets list. But this could be really annoying.

--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to