Yep, based on your description it sounds like Activity 1 is already
running and bound to the Service when you call it from Activity 2.
There's your leak.  See if you can put a test in Activity 1 before you
bind to the service.  If it is already running the service and bound,
don't do it again.  You might set a boolean flag in the Activity or
Service when you start and bind to it then check for that before you
call it and start again.
That's my educated guess.
Good luck.

On Jan 5, 10:17 am, Pawel Kapala <pawel.kap...@googlemail.com> wrote:
> Hello!
>
> It seems you're leaking the service connection in some way.
> Try doing some logging after you bind and before you unbind to the
> service, to see if you have unbound where needed (i.e.
> Activity.onDestroy). I guess, in your case, when you restart the
> activity 1, without previous unbind, the service connection is leaked.
> Do you call unbind in onDestroy method in your activities?
>
> Also try isolating the code, maybe you'll find the solution this way.
> Maybe, this also could be helpful in your 
> case:http://groups.google.com/group/android-developers/browse_thread/threa...
>
> --
> Best regards,
> Pawel
>
> On Jan 5, 2:11 am, Mike Collins <mike.d.coll...@gmail.com> wrote:
>
>
>
> > I'm getting aServiceConnectionLeakedmessage that I don't understand.
>
> > There are 3 activities and a remote service, all the activities use
> > the same
> > remote service.  The main window, activity 1, starts up, auto-starts
> > the
> > service and binds to it.  The user then starts activity 2 to do
> > something.
> > The user now wants activity 3, so the code in activity 2 puts some
> > data in
> > an intent and starts activity 1 via startActivity ().  When activity 1
> > is started,
> > it reads the data in the intent and starts activity 3.
>
> > This all works as expected except that while activity 3 is starting I
> > get theServiceConnectionLeakedwarning.  This is odd because the code that
> > unbinds from the service has never been called and the service
> > connection
> > continues to operate just fine.  If the user backs out of the main
> > window
> > the service is unbound and everything shuts down correctly.
>
> > Because the UI design doesn't want activity 2 to stack on top of 3, or
> > 3 on top of 2 I use a FLAG_ACTIVITY_CLEAR_TOP flag when starting
> > activity 1.  (I tested with this flag removed and the leakwarning
> > goes away but
> > I wind up with extra activities/windows in the stack).
>
> > To make it even a bit weirder, if I run through the same scenario
> > again,
> > e.g. close activity 3 to get back to activity 1, open 2, switch to 3
> > there is no
> > leakage the second and successive times, only the first time (near as
> > I
> > can tell).
>
> > any hints, thoughts?
>
> > tia,
> >   mike
>
> > I could pare it all down to an example if that is required/helpful.

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to