android - Wait for completion of AsyncTask and Loading of Map -
i writing code takes input 1 asynctask(httpurlconnection)
start asynctask(httpurlconnection)
uses information add markers google map.
the problem facing map has not loaded @ time when try add markers through onpostexecute
. when try use onmapready
data has not yet been downloaded.
is there way can wait both data load , map ready before attempting place markers?
synce question generic , provided no custom code, post "generic solution":
boolean isstep1done = false; boolean isstep2done = false; private class exampleoperation extends asynctask<string, void, string> { @override protected string doinbackground(string... params) { thread.sleep(1000); return "completed"; } @override protected void onpostexecute(string result) { isstep1done = true; continuelogic(); } @override protected void onpreexecute() {} @override protected void onprogressupdate(void... values) {} }
same thing exampleoperation 2, sets isstep2done true. then, if sequential, can continue, if independant, on each call continuelogic()
, , first step in function, check flags.
private void continuelogic(){ if(isstep1done && isstep2done ){ stuffs... } }
Comments
Post a Comment