[see below]

2011/1/14 John Gaby <jg...@gabysoft.com>

> > There is no onUpdate on configuration changes. The home screen recreates
> > your widget, then takes the most recent RemoteViews and applies it to the
> > widget.
> >
>
> I figured that it was recreating the Widget on rotation.  The problem
> is, I don't seem to be getting any messages to that effect, and have
> no way (that I can see) of re-establishing the connection.  How can I
> determine that a rotate has happened and set up a new onClick
> connection?
>

Like I said, you don't (determine or respond to an orientation change).

What you do, is make sure that every time your code pushes a RemoteViews
object into the home application for your widget, it's complete in all
respects:

- Has image resource ids;
- Has text stings;
- Has pending intents.

Don't do "incremental" widget updates, like you would do with a regular
activity - don't set the intents first, then the images, then the text
reflecting current information.

The home app runs as a separate process, and its state can get out-of-step
with your widget receiver. When it does, the only thing it has for
re-creating your widget is your most recent RemoteViews object. If it's
complete, and has all the parts, everything will work just fine. If it only
has the most recent text or image change, the earlier updates which had the
intents will be lost.

http://kmansoft.wordpress.com/2010/05/23/widgets-and-orientation-changes/

-- Kostya


> Thanks
>
> On Jan 14, 1:28 am, Kostya Vasilyev <kmans...@gmail.com> wrote:
> > Each and every update you push to the wigdget with RemoteViews has to
> have
> > complete widget state, including all images, text, and pending intents.
> >
> > There is no onUpdate on configuration changes. The home screen recreates
> > your widget, then takes the most recent RemoteViews and applies it to the
> > widget.
> >
> > If your codes tries to update the widget incrementally, piece-by-piece,
> with
> > one RemoteViews specifying the intent, and another, repeated, update
> setting
> > some changing information, then you end up with the most recent
> RemoteViews
> > only having your changing text, but no PendingIntent.
> >
> > This is very much unlike how Activities work, where the entire view
> > hierarchy is kept in memory for as long as the activity is on the screen
> > (and maybe longer).
> >
> > -- Kostya
> >
> > 2011/1/14 Anbu <anbu.ezhi...@gmail.com>
> >
> > > It is because, the widget becomes unresponsive when the display mode
> > > is changed from portrait to landscape. I had the same issue and I what
> > > I had done is for every RemoteView update I had send all the
> > > pendingintent to make it work
> >
> > > On Jan 14, 4:26 pm, John Gaby <jg...@gabysoft.com> wrote:
> > > > I have an App Widget on the Home screen which works fine until the
> > > > screen is auto-rotated.  At that point, the onClick connection (set
> up
> > > > via a call to setOnClickPendingIntent) is lost.  The only way I seem
> > > > to be able to get it back is to delete the Widget from the Home
> screen
> > > > and then add it back.  Is there some kind of message that tells me
> > > > that the screen has rotated that I need to respond to (and
> reestablish
> > > > the connection)?
> >
> > > > Thanks
> >
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to
> android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
> >
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

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

Reply via email to