You're  much safer if you explicitly connect them together.  There are many
ways a static object can be cleared or not yet set (by your process being
killed) when you aren't expecting it.

On Sat, Aug 29, 2009 at 2:42 PM, Rafael Martins <[email protected]>wrote:

>
> But I would like to know if there is any problem if I just call
> “public static” methods between activities and services, without using
> the IBinder object from the OnServiceConnected(ComponentName
> className, IBinder service) method. Calling directing the methods
> (“public static”) we don’t need this line from the example:
>
> mBoundService = ((LocalService.LocalBinder)service).getService();
>
> Do we need an object to communicate between services and activities?
> If we need, how a service can get an object of the activity class (to
> call activity's methods from the service)?
>
> Thank u for your attention.
>
> On 29 ago, 17:35, Dianne Hackborn <[email protected]> wrote:
> > Actually, the official example in the same process doesn't use binders
> for
> > communication at all:
> >
> >
> http://developer.android.com/guide/samples/ApiDemos/src/com/example/a...http://developer.android.com/guide/samples/ApiDemos/src/com/example/a.
> ..
> >
> > I don't know what we've done to lead so many people to jump to the much
> more
> > complicated remote service sample, but if your service and activity are
> in
> > the same process then I strongly recommend taking advantage of that like
> the
> > local example does.
> >
> > On Sat, Aug 29, 2009 at 9:04 AM, Rafael Martins <
> [email protected]>wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi, folks!
> >
> > > I'm searching for the simplest way to implement a communication
> > > between an activity and a service when both are running at the same
> > > process.
> >
> > > I've already made it using binders like the official example in the
> > > API Demo, but I want to call activity's methods from the service. So,
> > > I've made a public static method in the activity and it is working. I
> > > would like to understand the problems of doing this. Why we have to
> > > use binders if we can do all without them? How is the simplest way to
> > > do this?
> >
> > > Sorry if this is a silly question... :-)
> >
> > > Thank u all!
> >
> > --
> > 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.
> >
>


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