java - Issue in setting global array value with onPostExecute -
java - Issue in setting global array value with onPostExecute -
i trying set globally defined string[] placessuggestion;
using onpostexecute
of asynctask<string, string, string[]>
the onpostexecute
method looks :
@override protected void onpostexecute(string[] suggestionarray){ //log.d("suggestionarray", arrays.tostring(suggestionarray)); super.onpostexecute(suggestionarray); fillplacessuggestion(suggestionarray); log.d("suggestionarray", arrays.tostring(suggestionarray)); }
fillplacessuggestion
function looks :
public void fillplacessuggestion(string[] suggestionarray){ placessuggestion = suggestionarray; }
oncreate
method looks :
super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); sourceet = (edittext) findviewbyid(r.id.sourceedittext); destinationet = (edittext) findviewbyid(r.id.destinationedittext); new myasynctask().execute(); log.d("placessuggestion", arrays.tostring(placessuggestion));
the suggestionarray
log giving out expected value placesuggestion
log not.
can help me out in resolving issue new android development.
when seek log :
log.d("placessuggestion", arrays.tostring(placessuggestion));
the task not yet finished. wait if want right value placessuggestion
myasynctask task = new myasynctask(); task.execute(); if (task.get() != null) // waiting { log.d("placessuggestion", arrays.tostring(placessuggestion)); }
java android android-asynctask
Comments
Post a Comment