21.03.2011 17:01, Jake Colman пишет:
1) How does one provide multiple options for widget sizes?  Do you just
    add additional meta-data sections under the Receiver entry of the
    manifest?

Essentially by providing entirely separate widgets, each having its own size. They can share implementation (Java code, drawables, layouts), but they should be declared as separate widgets as seen by Android.

2) How does one set options that are unique to a given instance?  The app
    currently uses SharedPreferences for all of its configuration.  But
    if both instances are running in the same context, how can each
    widget know how it is configured as distinct from another instance?

Widget ids are persistent until a widget is removed. Store values in shared preferences (or some other persistence mechanism) keyed by widget id.

3) The app uses a service that is started by an alarm in order to do the
    updating.  When the alarm is triggered, the service calculates the
    time remaining until the event and then it updates the remote view.
    Do both widgets share the same service?  I'd that is the case since
    it all one app with just multiple widget instances.  If that's the
    case, how can the service know which widget it is updating?

Use

AppWidgetManager.updateAppWidget(int widgetId, RemoteViews views)

to update only one particular widget.

You can get the ids when needed outside onUpdate like this:

AppWidgetManager manager = AppWidgetManager.getInstance(context);
ComponentName widgetClassName = new ComponentName(context, <your WidgetProviderClass>);
int[] widgetIds = manager.getAppWidgetIds(widgetClassName);

Be aware that in some cases, there may be widget ids that refer to non-existent widgets.

I documented my workaround for this issue here:

http://kmansoft.wordpress.com/2010/06/22/per-widget-options-stale-widgets/

--
Kostya Vasilyev -- 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