05.05.2011 14:22, Niall ?????:
I think I understand you... but I'm not sure that I do completely.

Having not used services for updating (or for managing updates) let me first ask what you mean by pushing updates so I don't misunderstand.

By pushing an update I mean:

1 - Instantiating RemoteViews;
2 - Setting some values in it;
3 - Calling AppWidgetManager.updateAppWidget.

I call it "pushing" because the RemoteViews object is sent over to the Launcher, which then displays the widget.

Does that mean that in a service I instantiate an appWidgetManager, and then call its updateAppWidget with one RemoteViews? The RemoteViews coming from some update function I write? I think I can do that.

Yes. In a service or not. Not all widgets need a service just to build the update.

And does that as a result mean that to fix the orientation issues that this thread's about when I get an onConfigurationChanged notification I do the same thing with the appWidgetManager and its updateAppWidget method?

You won't need the service with onConfigurationChanged if you do this.

The problem with orientation changes happens when you update your widget in several distinct updates: one to push the pending intents and some initial values, then another to update some text view, etc.

The launcher only keeps one RemoteViews for each widget - the most recent one. If it needs to recreate the widget, it does this by reloading the widget's layout, and applying this saved RemoteViews.

So, you want to make sure that your RemoteViews objects can completely specify the current state of your widget.


I think that makes sense. And that would be preferable to broadcasting from the service back to the appwidget?

The service can be killed, and thus not receive any config change notificaitons. The service also doesn't help if the Launcher (the home screen) is killed.

-- Kostya

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