On Fri, Jun 25, 2010 at 8:45 AM, Mark Murphy <[email protected]>wrote:

> -- that the performance overhead I thought we had with AIDL/Binder
> within a process isn't really there? Or...
>

AIDL/Binder by design don't have a performance impact when making a call in
the same process.  This turns into a direct call on to the target's
interface implementation.  (Note in the future we may introduce indirection
there to make the semantics of the local case better match that of remote
calls...  but not today.)

The big thing this introduces is a whole lot more effort and complexity for
the developer, as they now need to deal with AIDL interfaces.

Also note that if you know this service is in the same process, you can use
the same local calling trick as the LocalService sample -- pass it an
IBinder, which the service simply casts to a concrete local object to call.


> -- that the overhead is there, should be avoided, ResultReceiver is a
> bad idea, and its use in stuff like the Google I|O 2010 conference app
> is merely unfortunate?
>

If the purpose of this code (and I haven't looked at it to know) is to send
a command to the service and get told later when it is done, then this is a
reasonable approach.  There are some potential edge cases where the result
won't be delivered though (if the process is in the background and gets
killed and its service restarted), so I would recommend giving it a
PendingIntent to deliver a result to the activity rather than an interface
to a live object.  You can make this with Activity.createPendingResult().

On the other hand, if the purpose of this is to tell the service about the
activity running for it to know about and send information back during that
time, it is bad because this is not the semantics of startService().  You
want to use bindService() for that.

-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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