Android AsyncTask don't return correct Result

后端 未结 3 717
抹茶落季
抹茶落季 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:14

    you can't return value from asyncTask at all, you can parse result, do what ever you want inside doInbackground() or in onPostExecute(), if you want more flexibility, you can call a method exist out of the asyncTask passing the result from onPostexecute():

    private void continueWithResult(String data){
    //do whatever you want with the json passed from onPostExecute()
    }
    
    class ProcessTask extends AsyncTask {
    :
    :
        @Override
        protected void onPostExecute(String result) {
            continueWithResult(result);
        }
    :
    :
    

    and you really need to read the link posted by JTsunami

提交回复
热议问题