I am testing a simple widget in android and use Alarms to regularly update TextView. The problem is that in the BroadcastReceiver class, I cannot access the TextView element that I want to receive when the alarm expires. The class is called correctly because Toast, which I put in, gives the corresponding message. The following code refers to the class where I configure the widget and set the timers.
public void onCreate(Bundle bundle) { super.onCreate(bundle); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if(extras != null){ mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetConfigure.this); RemoteViews views = new RemoteViews(WidgetConfigure.this.getPackageName(), R.layout.widget_layout); views.setTextViewText(R.id.quote, "Widget Loaded From Activity"); appWidgetManager.updateAppWidget(mWidgetId, views); setTimer();
Now I want to update the same TextView when BroadCastReceiver is called after the timer expires. I tried the code provided in the ExampleAppWidget example provided in the demo versions of android api and this does not work. How can I set the required text?
source share