简体   繁体   中英

Android send data from IntentService to Activity

i have a service which fetches some data from network.i am sending data download finish type of messages through messenger object like this

messangerClient.send(Message.obtain(null, MyActivity.DOWNLOAD_SUCESS));

and getting it in my activity successfully.But now i need to send data from my service to my activity.I cannot use Parcel framework because it is supported from 2.2.So i am thinking to send it via setData() using bundle.But i am unable to figure out how to do this.

Please anybody have any idea to how to do this. Thanks

if you are binding to the service, in the service connection callback, you will receive the IBinder object, use that and fetch your service object and you can call methods on it like a normal object methods

look at the way LocalService object is captured in the example mentioned in android documentation

如果要通过服务启动活动,则可以通过Intent传递数据。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM