Android AsyncTask don't return correct Result

后端 未结 3 710
抹茶落季
抹茶落季 2020-12-11 11:22

for one of projects i want to use Ksoap with AsyncTask. now in this below code AsyncTask can work correctly but after return result to

3条回答
  •  死守一世寂寞
    2020-12-11 12:16

    You cannot get the return value of AsyncTask by

    tmp = String.valueOf(p.execute());

    This is because Android app doesn't wait for AsyncTask to return a value to move to next line.

    You need to use the onPostExecute() Method to process the return value of an AsyncTask .

    You can refer AsyncTask: where does the return value of doInBackground() go? for more syntax and more information.

提交回复
热议问题