Note that there are some explanatory texts on larger screens.

plurals
  1. POWidget Not Updating Views
    text
    copied!<p>So basically my Widget updates, according to my LogCat, and the TextView in my Widget's Layout is not. It updates when it first starts, but what I am trying to do is update it artificially using an intent after a BrocastReceiver. The intent works fine, the onUpdate runs after the onReceive, but the text is not updated. I have a feeling it has to do with the fact that a different context, AppWidgetManager, or appWidgetIds are being used.</p> <p>Here are my methods:</p> <pre><code>String sent = "0"; @Override public void onReceive(Context context, Intent intent){ String action = intent.getAction(); if(action != null &amp;&amp; action.equals("27")){ Log.i("Updating", "UPDATING WIDGET"); sent = intent.getStringExtra("Sent"); onUpdate(context,AppWidgetManager.getInstance(context), new int[]{0}); } super.onReceive(context, intent); } @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){ Log.i("Widget","onUpdate"); String begin = "Sent "; String end = " Texts Since Last Visit"; final int N = appWidgetIds.length; for(int i = 0 ; i &lt; N; i++){ int widgetId = appWidgetIds[i]; Intent intent = new Intent(context,History.class); PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); views.setOnClickPendingIntent(R.id.LLwidget, pi); Log.i("Widget","Sent: " + sent); views.setTextViewText(R.id.SentTextView, begin + sent + end); appWidgetManager.updateAppWidget(widgetId, views); } } </code></pre> <p>Manifest:</p> <pre><code> &lt;receiver android:name="MyWidgetProvider"&gt; &lt;intent-filter&gt; &lt;action android:name="android.appwidget.action.APPWIDGET_UPDATE" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info"/&gt; &lt;/receiver&gt; </code></pre> <p>widget_info:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:updatePeriodMillis="30000" android:initialLayout="@layout/widget_layout" android:minHeight="72dip" android:minWidth="146dip"&gt; &lt;/appwidget-provider&gt; </code></pre> <p>I think that is all the necessary information considering I know for sure that the intent works and the onUpdate runs.</p> <p>Hopefully someone can help me because this is my first attempt at a widget and my brain is a little frazzled because of lack of sleep over this. Thanks, Brandon</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