java - AsyncTask of 'Activity A' doesn't execute if I re-open 'Activity A' before the original AsyncTask has finished executing -
i have asynctask implemented follows:
asynctask asynctask = new asynctask() { @override protected object doinbackground(object[] params) { //downloading images google places api } @override protected void onpostexecute(object o) { } } }; asynctask.execute();
this asynctask triggered run multiple times , it's executed scope of doinbackground() method of asynctask. runs fine the first time load activity, , if let data download , exit activity (so onstop() called) , reopen activity runs fine then, but, if exit activity before data downloaded won't run when reopen activity.
does know why is? can recommend better approach doesn't involve asyntask?
note: have tried using executeonexecutor() hasn't solved issue.
thanks in advance
asynctasks run on single thread, in order received. if exit before asynctask finishes, continues run. if relaunch before finishes, waits in task queue until original run finished before can run. can avoid telling run on own queue. although better method may loader if fetching same data anyway (that allow not run second time use results of first run).
Comments
Post a Comment