Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've encountered the same problems when developing collections' AppWidgets. Many times the following would happened:</p> <ul> <li>On rotation, the ListView entirely dissapeared;</li> <li>The button listeners (actually called <code>PendingIntents</code>) stopped responding;</li> <li>Changes in images via <code>setImageViewResource</code> didn't get updated;</li> </ul> <p>.. and so on. I came to the same conclusion as you did: <strong>android destroys and recreates widget views using the last RemoteViews call which it stores in some secret place</strong>. After acknowledging that, it was a question of <em>fine-timing</em> the calls to <code>AppWidgetManager.getInstance(context).updateAppWidget()</code> because I wanted to disable the <em>clickListeners (or PendingIntents)</em> after telling the ListView to refresh itself (it was a network operation of calling web-services and retrieving a non-trivial amount of data) and wanted to enabled the listeners after the ListView finished loading while maintaining the RemoteViews fully loaded in order to handle a rotation. </p> <p>I was this close to giving up and using as an alternative..</p> <blockquote> <p>Is there anyway to intercept android when the screen orientation changes and force it to redraw the whole widget?</p> </blockquote> <p>.. a service that <strong>does</strong> intercept Android rotation changes, unlike an AppWidget. If you're running out of options, I'd suggest you'd try it out:</p> <pre><code>public class MyWidget extends AppWidgetProvider { @Override public void onConfigurationChanged(Configuration newConfig) { // insert code here } } </code></pre> <p>Find out more about the service <a href="https://stackoverflow.com/questions/3503114/after-orientation-change-buttons-on-a-widget-are-not-responding">here in StackOverflow</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload