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

前端 未结 17 2205
鱼传尺愫
鱼传尺愫 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:13

    You can try this code in your Main class. That worked for me, but i have implemented methods in other way

    try {
        String receivedData = new AsyncTask().execute("http://yourdomain.com/yourscript.php").get();
    } 
    catch (ExecutionException | InterruptedException ei) {
        ei.printStackTrace();
    }
    

提交回复
热议问题