How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class?

前端 未结 17 2160
鱼传尺愫
鱼传尺愫 2020-11-21 04:50

I have this two classes. My main Activity and the one that extends the AsyncTask, Now in my main Activity I need to get the result from the OnPostExecute(

17条回答
  •  借酒劲吻你
    2020-11-21 05:21

    in your Oncreate():

    `

    myTask.execute("url");
    String result = "";
    try {
          result = myTask.get().toString();
    } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
    }catch (ExecutionException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
    

    }`

提交回复
热议问题