• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Clicking on a Widget stops working when the screen orienation is changed.

dodald

Newbie
I have a widget in an very simple app that I am wrote; it shows some information and is updated every couple of hours. Normally when the user clicks on the widget it brings up an Activity; but after the user changes the screen orientation or slides out the Keyboard they can no longer click on the widget. The only way to get the clicking working again is the delete and re-add the widget.

The code I am using comes from this example: App Widgets | Android Developers

Has anyone else ran into this?
 
Jeff Sharkey said:
Make sure you're 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.
From:

[android-developers] Re: Widget not working properly when changing orie

Figure I would post what I found to be the solution here in case someone else stumbles on this problem:

I was updating the Widget's view from a service because I was making a Web Service call, but I was adding the click handler from the onUpdate method.

I was also updating the view from another place in my app. When I updated all of the updates to include the click handler it started working!
 
Back
Top Bottom