Changing a TextView on an Android Widget from within the onReceive method rather than onUpdate -
i'm developing application runs service regularly sends broadcasts current state. broadcasts received appwidgetprovider
using onreceive
method:
@override public void onreceive(context context, intent intent) { super.onreceive(context, intent); if (intent.getaction().equals(action_status_changed)) { bundle b = intent.getbundleextra("updateinfo"); remoteviews views = new remoteviews(context.getpackagename(), r.layout.widget_app_control); // doesn't work reason views.settextviewtext(r.id.informationtextview, b.getstring(myservice.bit_of_information)); // update widgets appwidgetmanager appwidgetmanager = appwidgetmanager.getinstance(context); int[] appwidgetids = appwidgetmanager.getappwidgetids(new componentname(context, appcontrolwidgetprovider.class)); this.onupdate(context, appwidgetmanager, appwidgetids); } }
however, though i've added call onupdate
, new text meant set using settextviewtext
not make actual widgets. if make bundle i've taken information available whole instance of class (saving in attribute, sake of testing) , make exact same call settextviewtext
within onupdate
method, textview
updates expected.
i've browsed regarding topic extent now, everywhere else setting textview
text within onreceive
method in exact same manner i'm doing (unless i'm missing something, is) seems work fine.
Comments
Post a Comment