Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After a lot of blood, sweat, and tears I found the solution. I am going to hold off on confirming this answer for a few days to make sure that the error doesn't pop back up, but after a lot of observation I think it is resolved.</p> <p>So I was right in my edited comments in the original question. It wasn't the update method of the AppWidgetManager that caused the problem, but rather some other Android process which caused the app widget to recreate itself. Unfortunately I couldn't isolate that trigger, but I did find a solution.</p> <p>In my RemoteViewsFactory class (basically the wrapper which is used to load the data set), I had a block of code that looked like this:</p> <pre><code>RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.widget_layout); if(mItems.size() == 0) views.setViewVisibility(R.id.widget_empty, View.VISIBLE); else views.setViewVisibility(R.id.widget_empty, View.GONE); AppWidgetManager manager = AppWidgetManager.getInstance(mContext); ComponentName widgetCompName = new ComponentName(mContext, WidgetReceiver.class); manager.updateAppWidget(widgetCompName, views); </code></pre> <p>Basically, if the list was empty, I showed a Loading message that took up the entire area where the listview is located. If the list wasn't empty, I'd just hide that message.</p> <p>So this is what was happening: When the factory was destroyed (presumably for memory purposes) the widget <em>itself</em> was not. So all of the code which sets the intents for the data and stuff was not run. However, the factory was recreated, which ran that block of code which updated the app widget with the new remote views object. This remote views object didn't do any of the methods that you see in my onUpdate() method I originally posted, so all of its features didn't work.</p> <p>Moral of the story: DON'T use <code>updateAppWidget</code> in your RemoteViewsFactory class! Now it may work if you run all the necessary lines, but I can't confirm that.</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