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

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

    You need to use "protocols" to delegate or provide data to the AsynTask.

    Delegates and Data Sources

    A delegate is an object that acts on behalf of, or in coordination with, another object when that object encounters an event in a program. (Apple definition)

    protocols are interfaces that define some methods to delegate some behaviors.

    Here is a complete example!!!

提交回复
热议问题