Tuesday, July 12, 2011

Re: [android-developers] Re: Accessing local data in a bound service

On Tue, Jul 12, 2011 at 7:54 PM, Ab Caballero <ahb3@mac.com> wrote:
> What i wanted to do then was pass data to the service (one parameter)
> by using putExtra() but i couldn't figure out how to get it to work.
> Is it possible to use putExtra() while binding to a running service?

To a running service, no. onBind() is only called once per distinct
Intent, and you do not want to bind multiple times from the same
activity, anyway.

However, bear in mind that the primary -- perhaps complete -- reason
you are binding is to get a Binder. You can supply TRIP_INFO via a
method call on the Binder in onServiceConnected(). Passing data via
extras is used when you are using startService() to send commands,
rather than binding.

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

Warescription: Three Android Books, Plus Updates, One Low Price!

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

No comments:

Post a Comment