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

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

    You can do it in a few lines, just override onPostExecute when you call your AsyncTask. Here is an example for you:

    new AasyncTask()
    {
        @Override public void onPostExecute(String result)
        {
           // do whatever you want with result 
        }
    }.execute(a.targetServer);
    

    I hope it helped you, happy codding :)

提交回复
热议问题