1

I have a funcation updateAtServer. There is a asyncTask. I want to finish this background thread completely first and after that this function should be return the values like as true or false.

But background thread is running and I am getting return values of that function before completing the asyncTask.

public static boolean hasUpdateAtServer_DeleteScore = false;
public static boolean hasUpdateAtServer_score= false;
public static boolean hasUpdateAtServer_swing= false;
public static boolean hasUpdateAtServer_courseDetailsHoles= false;

public synchronized static boolean updateAtServer(Context context) {

    new UpdateIntoServer(context).execute();

    return hasUpdateAtServer_DeleteScore && hasUpdateAtServer_score
            && hasUpdateAtServer_swing && hasUpdateAtServer_courseDetailsHoles;

}
Rahul Rawat
  • 999
  • 2
  • 17
  • 40
  • 2
    Use Listeners and post response from async task, implement it where you call this method – Suneel Prakash Sep 23 '14 at 11:58
  • http://stackoverflow.com/questions/16912768/asynctasks-get-method-is-there-any-scenario-where-it-is-actually-the-best-op – praveen Sep 23 '14 at 11:59
  • asynctask (InputType, progressupdate , outputtype) its the third parm that is returned from doinbackground to onPostExecute. – danny117 Sep 23 '14 at 12:46

0 Answers0