tags:

views:

115

answers:

1

My widget stops working (becomes unresponsive to a button press) when the view changes from portrait to landscape or vica versa, does anyone know why it does this and if there is a fix?

EDIT: found the solution. I needed to sending all PendingIntents across with each RemoteViews update, even if they've already been set. When the orientation changes, the layout is inflated and only the most-recently cached RemoteViews is applied over it.

+1  A: 

When the device orientation changed, if you didn't specify otherwise, Android destroyed your activity and recreate it.

To make Android app development easier, the Android system automatically handles configuration change events and restarts the current activity with the new configuration. This is the default behavior that lets you declare resources like layouts and drawables based on the orientation, screen size, locale, etc.

While this behavior is really powerful, since your application adapts automatically to the device's configuration at runtime, it is sometimes confusing for new Android developers, who wonder why their activity is destroyed and recreated.

Maybe something wrong happens when your application is restarted.. Post your log

Have a look here

hara
thanks for the response. In my post I accidentally said app when I meant to say widget, but it seems something similar is happening. While looking for a solution I found this answer "Make sure your sending all PendingIntents across with each RemoteViews update, even if they've already been set. When the orientation changes, the layout is inflated and only the most-recently cached RemoteViews is applied over it." but how do I do that?
John