Thursday, November 10, 2011

[android-developers] Re: How to communicate between an Android Broadcast Receiver and a RemoteService

Thanks everyone for the help, I managed to implement a communication
to the service using the intent. What I missed was having the intent-
filter android:exported=true option set in the manifest.

Now I can communicate and pass data to the service using the
startService(..) method that streets of boston pointed out. Ideally, I
would still prefer a way to "bind" to the remote service and use aidl
(as this would minimize the intent filter handling I have to do within
the service), but it seems as though it cannot be done due to the life
cycle of the BroadcastReceiver.

On Nov 10, 7:50 pm, Dianne Hackborn <hack...@android.com> wrote:
> If you just want to communicate with a service if it is already running,
> you can use this:
>
> http://developer.android.com/reference/android/content/BroadcastRecei...,
> android.content.Intent)
>
> On Thu, Nov 10, 2011 at 3:06 PM, Shaun Shirey <shaun.shi...@gmail.com>wrote:
>
>
>
> > I would love to do that, the only problem that I'm running into is
> > that I can't bind to the service (via a service connection).
>
> > The startService works fine but the bind won't work in a
> > broadcastreceiver object. If I can't bind to the service, I don't
> > believe there is a way to communicate with it?
>
> > On Nov 10, 9:17 am, Streets Of Boston <flyingdutc...@gmail.com> wrote:
> > > Use Intents. Put data in the Intent's 'extras'.
> > > Put this Intent in the startService call. The Service's onStartCommand
> > will
> > > be called with this Intent and you can handle it there.
>
> > > Or you can define an AIDL that your service implements. Bind to the
> > service
> > > and communicate with the service through the methods defined in this
> > AIDL.
>
> > --
> > 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
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> 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 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