On Tue, Sep 14, 2010 at 11:08 AM, Bret Foreman <[email protected]> wrote:
> The UI needs to get data back (asynchronously) from the IntentService,
> which means using AIDL, onBind, and all that.

Not necessarily, and not from an IntentService.

> Of course, that "separate thread" stuff in the AIDL docs in nonsense.
> If you spawn a separate thread in an Activity it will get blown up in
> OnDestroy. But what do they mean by "By defualt"? Are there cases
> where the IPC can be asynchronous? Is that what is meant by the text
> in the IntentService docs "may not happen on the main thread"? How
> does this work?

Do not use AIDL-based IPC with an IntentService. Use private
broadcasts, or createPendingResult():

http://github.com/commonsguy/cw-advandroid/tree/master/AdvServices/RemoteClientUnbound/
http://github.com/commonsguy/cw-advandroid/tree/master/AdvServices/RemoteServiceUnbound/

There is also a ResultReceiver you could use, though I haven't gotten
that to work well.

Basically, you pass enough information in the Intent to the
IntentService so it knows how to get data back to the requestor.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to