Wednesday, 15 February 2012

java - Wait for a thread/asynctask to complete in a method so that it can be the returned value of the method -



java - Wait for a thread/asynctask to complete in a method so that it can be the returned value of the method -

hello stack overflowers,

i working on android application , making todo list application. 1 of requirements check on webserver if device has registered on server. understand has done in background thread avoid ui thread lockups.

i have method check follows:

public string isregisteredonserver { // check here on server homecoming resultofservercheck; }

how can implement it, or there alternatives approaches this?

thanks in advance

you can using asynctask

new asynctask<string, void, string>() { @override protected void doinbackground(string str) { // time consuming code here homecoming result; //return string here } @override protected void onpostexecute(string result) { setresultvalue(result); } }.execute(); private void setresultvalue(string value) { // string here }

java android multithreading android-asynctask

No comments:

Post a Comment