I have an IntentService which runs an http request and returns me an ArrayList of Objects.
How am I going to send these data back to the Activity ?
I have searched StackOverflow and googled about it, but most answers have to do with Strings or ints. It's not a String not an Int just an arrayList of custom objects. Thanks
Use greenrobot's EventBus or Square's Otto as an event bus. Have the service post an event containing your data. Have the activity subscribe for those events on the bus, then do something with the events.
You can use BroadCast receiver
to send the data from IntentService
to Activity
.
Intent intent = new Intent();
intent.setAction("your_action_here");
intent.putExtra("key_data", <your_arraylist_here>);
sendBroadcast(intentUpdate);
You need to have this broadcast receiver
registered in the activity where you want to receive the data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.