java - Android - Arraylist size always zero -


i try make application. use facebook sdk , can login facebook. app getting movies user likes. can graph api , can add name of movie arraylist. ok far. when try access in oncreate method arraylist null. when use debug can see json value. how can solve this. know english not trying explain issue. hope :)

public class list extends appcompatactivity {      arraylist<string> movielist = new arraylist<string>();      public void getinfo(){         graphrequest request = graphrequest.newmerequest(                 accesstoken.getcurrentaccesstoken(),                 new graphrequest.graphjsonobjectcallback() {                     @override                     public void oncompleted(jsonobject object, graphresponse response) {                         jsonobject jsonobject = response.getjsonobject();                         try {                             jsonobject movies = jsonobject.getjsonobject("movies");                             jsonarray data = movies.getjsonarray("data");                             (int = 0; i<data.length();i++){                                 jsonobject objectdata = data.getjsonobject(i);                                 string moviename = objectdata.getstring("name");                                 movielist.add(moviename);                             }                         }catch (jsonexception e){                             e.printstacktrace();                         }                      }                 });          bundle parameters = new bundle();         parameters.putstring("fields", "movies");         request.setparameters(parameters);         request.executeasync();     }      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_list);         getinfo();          this.settitle(movielist.get(0));        } } 

it's empty cause request async , hasn't end when try access array... try accessing @ oncompleted


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -