Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>My UpdateService.java is just getting the set preferences and customizing the widget's appearance, so I don't think it could possibly be related to my issue.</p> </blockquote> <p>It is possible it is related, in as much that you could use it to "refresh" the pending intent. I have a similar issue in my appwidget that an image button stops responding to clicks after some random run time (hours).</p> <p>I found this thread: <a href="https://stackoverflow.com/questions/5851634/appwidget-button-onclick-stops-working">AppWidget Button onClick stops working</a></p> <p>And this quote:</p> <blockquote> <p>The pending intent is "burned" after each use. You need to set it again. Or wait for the widget to get refreshed, then it happens, too, but that's probably not the desired way.</p> </blockquote> <p>Given that the widget update time normally is set at many hours or days (mine is 86400000 milli seconds) in order to prevent the phone going out of suspend every so many minutes your widget will not often run onUpdate. It is possible that setting the pending intent ALSO in the update service will prevent the problem you describe.Each time the update service runs the pending intent is re-created.</p> <p>I have today added this possible fix to my appwidget and I have to wait and see if the fix really works, but so far so good.</p> <p>I added the following code in the update service' loop where it refreshes each widget:</p> <pre><code>for (int i=0; i&lt;appWidgetIds.length; i++) { appWidgetId=appWidgetIds[i]; /* other stuff to do */ RemoteViews views=new RemoteViews(context.getPackageName(), R.layout.example_appwidget); /* here you "refresh" the pending intent for the button */ Intent clickintent=new Intent("net.example.appwidget.ACTION_WIDGET_CLICK"); PendingIntent pendingIntentClick=PendingIntent.getBroadcast(context, 0, clickintent, 0); views.setOnClickPendingIntent(R.id.example_appwidget_button, pendingIntentClick); appWidgetManager.updateAppWidget(appWidgetId, views); /* then tell the widget manager to update */ appWidgetManager.updateAppWidget(appWidgetId, views); } </code></pre>
 

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