android - Updating text in a widget on an event -
i created class downloads text internet , want take text , update textview
in widget. know event (ondownloadcompletelistener) getting triggered because i'm logging can't figure out how update textview within event. know it's newbie mistake, not sure i'm missing.
public class widget extends appwidgetprovider{ internettext internettext; //handles downloading text internet remoteviews views; public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { final int n = appwidgetids.length; // perform loop procedure each app widget belongs provider (int i=0; i<n; i++) { int appwidgetid = appwidgetids[i]; // create intent launch exampleactivity intent intent = new intent(context, mainactivity.class); pendingintent pendingintent = pendingintent.getactivity(context, 0, intent, 0); // layout app widget , attach on-click listener // button views = new remoteviews(context.getpackagename(), r.layout.widget); views.setonclickpendingintent(r.id.tvwidgetverse, pendingintent); internettext = new internettext(context); internettext.setondownloadcompletelistener(new ondownloadcompletelistener() { @override public void onevent() { thetext thetext = internettext.downloadedtext(); //the text object log.i("", "widget text downloaded " + thetext.gettext()); //this fires know we've downloaded text textstyling textstyle = new textstyling(); //*****this i'm having problem******** views.settextviewtext(r.id.tvwidgettext, html.fromhtml(textstyle.boldwords(thetext.gettext()))); //this never updates } }); internettext.gettext(); // tell appwidgetmanager perform update on current app widget appwidgetmanager.updateappwidget(appwidgetid, views); } } }
ok, figured out. have call appwidgetmanager.updateappwidget()
within event. knew no-brainer...
appwidgetmanager.updateappwidget(appwidgetid, views);
which means have make appwidgetmanager , appwidgetid final
public void onupdate(context context, final appwidgetmanager appwidgetmanager, int[] appwidgetids) { ... }
Comments
Post a Comment