Saturday, September 3, 2011

[android-developers] Re: Service callback references "ghost" instance of my activity

Hello, could you post the code?
Do you have access to third party service's code?


On Aug 27, 9:56 am, Jason <dummytes...@gmail.com> wrote:
> Hello all,
>
> I'm running into an issue in my app and am trying to determine the
> root cause.
>
> Here's some background info:
> I have an activity that can be triggered from various places
> throughout my application.  I am also using a service developed by a
> third party ( it is a library that i make calls to).
>
> The issue:
>
>     Instance A of my activity starts up.  in onCreate i bind to the
> service and make a function call to it.  I then correctly receive
> callbacks from the service based on what i send to it.  As my activity
> executes, it is setting various local variables.  Once my activity is
> complete onDestroy() gets called and i unbind from the Service.
> Everything works correctly.
>     Later I start Instance B of my activity.  I correctly set my local
> variables, call onCreate, and issue my function call to the service.
> the issue arises when i receive a callback.  The callback returns to
> the already destroyed "ghost" instance A instead of instance B that
> started the service.  I then find that all my local variables are
> screwed up b/c now my activity is using all of instance A's variables
> (which screws up my execution in instance B).  The activity still
> continues to execute, but the mismatch in variables cause it to hang/
> fail/have weird behavior.
>     My activity is single_top and there are not two instances of my
> activity running concurrently.
>
> Further, i notice when I kill the service process and re-execute my
> activity everything works fine.  I do run into the issue again once i
> run it the second time.
>
> So 3 questions:
> 1) Is it possible for instance A to be referenced even after
> onDestroy() is called on it?
> 2) Is there a way to immediately invoke the garbage collector to clear
> out the memory space instance A is occupying?
> 3) Is this a problem with the third party service?  In my code i
> perform bind in onCreate and unbind in onDestroy... I am stumped as to
> why my destroyed instance A is still being referenced when the service
> was bound to and started by B.
>
> Thanks,
> Jason

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