Android AsyncTask: what is difference between execute() and get()? -
should write smth that
return task.exec(session, state).get(json_timeout, timeunit.milliseconds);
or can this
task.exec(session, state, result); return result;
a have read documentation found, failed find answer. bad...
do not use get()
. block ui thread until asynctask finishes execution no longer makes asynchronous.
use execute , invoke asynctask
new task().exec(session, state, result);
also can pass params constructor of asynctask
or doinbackground()
http://developer.android.com/reference/android/os/asynctask.html
public final result ()
added in api level 3 waits if necessary computation complete, , retrieves result.
you can make asynctask inner class of activity class , update ui in onpostexecute
.
if asynctask in different file can use interface.
Comments
Post a Comment