So I have an app widget that is refreshing nicely, loading a new bitmap into an ImageView
regularly like clockwork. Then, at some point, and silently, it will stop updating any further. I can tell from the log, and from activity at a server which my code is querying, that the widget is actually still continuing to fire regularly (via broadcasts caught by onReceive()
, and doing its stuff as expected. The only thing that isn't happening is that the widget content is not updating.
So, in the code which executes when the widget fires, I'm creating a new RemoteViews and adding stuff to it, including loading a new bitmap via remoteViews.setImageViewBitmap(imageViewID, bmp)
, and then finally calling appWidgetManager.updateAppWidget(appWidgetId, remoteViews)
to update the widget content. Works nicely... until it stops working.
I'm not sure what code to post, because the thing works just fine 99% of the time, but occasionally the updateAppWidget()
stops working, for no apparent reason. Seems like it's a system issue, rather than a bug in my code, but I could be wrong.
The only thing which appears to maybe prompt this is when there are changes in connectivity, e.g. going from no signal to WiFi, maybe frequent such changes. It seems to happen more in those situations.
And once the widget freezes, the only thing which unfreezes it is restarting the device. Without restarting, even removing the widget and adding a new one doesn't work. In fact, adding a new one results in a dead widget that doesn't even respond to a click to open up the Config Activity, presumably because remoteViews.setOnClickPendingIntent(R.id.widget, configPendingIntent)
is ignored like everything else in the RemoteViews
I carefully construct and send to appWidgetManager.updateAppWidget()
.
It seems to be pretty much as described by many others here:
https://code.google.com/p/android/issues/detail?id=28216
and as yet there seems to be no known cure. The post at https://code.google.com/p/android/issues/detail?id=28216#c56 seemed to offer some promise, but I've tried calling AppWidgetHost.startListening()
in various places, including at regular intervals via a repeating alarm to see if I could kickstart the widget, but nothing seems to work.
And other users (rather than developers) seem to be seeing this issue too: http://androidforums.com/threads/clock-widget-keeps-freezing-please-help.530333/
Any ideas? It's slowly driving me mad!