How to make my android widget wait until i fetch content -
i'm working on android widget fetches content api.
what i'm using custom function uses callback included in onupdate => api.getlastitems(mycallback).
mywidget provider :
public void onupdate(context _context, appwidgetmanager _appwidgetmanager,int[] _appwidgetids) { api.getlastitems(new requestcallback() { @override public void onfinish(object object) { arraylist<string> announcs_titles = (arraylist<string>)object; final int n = widgetid.length; (int = 0; < n; i++) { intent myintent = new intent(context, widgetservice.class); myintent.putextra(appwidgetmanager.extra_appwidget_id,widgetid[i]); myintent.putstringarraylistextra("itemstitles",items_titles); ... appwidgetmanager.updateappwidget(widgetid[i], widget); } } }); super.onupdate(context, appwidgetmanager, widgetid); } because remoteviewsservice.remoteviewsfactory use special function getviewat(int position) needs position begin working, used kind of structure let widget wait until arraylist of items gets filled.
is right or there method that? , how refresh widget clickevent (i mean way it, not pendingintent.getactivity code)
i fixed problem using custom function : load() call inside widgetprovider onreceive()
@override public void onreceive(final context context, intent intent) { // check if nothing loading , call function load() } private void load(){ ... //1- fetch content api , set result global variable //2- call onupdate(context, appwidgetmanager, appwidgetids); } @override public void onupdate(context context, appwidgetmanager appwidgetmanager,int[] appwidgetids) { //add condition check loading completed , global variable contains something. } if needs method, contact me
Comments
Post a Comment