Return data from AsyncTask class

前端 未结 6 1529
清酒与你
清酒与你 2020-11-29 04:03

How do I get the data from my AsyncTask? My MainActivity is calling the DataCall.getJSON function that triggers the AsyncTask but I am not sure how to get the data back to

6条回答
  •  星月不相逢
    2020-11-29 04:20

    Some options:

    a) Make your bean implement Serializable interface, you can then pass your bean through Intent.

    b) Implement Application interface (you need to make an entry in manifest), Have setter\getter method in your Application class. You can set your bean in Application from AsyncTask and later retrieve from Activity.

提交回复
热议问题