Hello, In my program I need to pass 'live' Objects from one activity to another. Those are most likely not parcelable and most likely not just data. I figured out I could use a local Service to provide a cross-Activity data sharing. It's just a map from unique ids to Object. Initial experimentation went great.
However, I am having serious trouble with a difference between the back and the up button. The application is set up as follows: there's a MainMenu Activity which launches the service by means of bindService(..., BIND_AUTO_CREATE). Other "inner" activities bind by bindService(..., 0). They unbind on onDestroy, mostly because I'm lazy. Now, because of the way I have setup activities, the up and the back buttons should be equivalent. And indeed they are. Sort of. When I push the back 'hardware' button I have: onPause, onStop, onDestroy as expected. Here, I de-register the callback and... at a certain point I got a huge error by pushing the 'back' button relating to a leaking window created in my onServiceDisconnect. Indeed, I show an error dialog when this happens with the only option being calling finish(). I figured out I needed to keep track of unbinding status. It was my understanding onServiceDisconnect wouldn't get called when I unregister... it turns out the 'back' button produces this sequence of calls: onPause, onServiceDisconnected, onServiceConnected (MainMenu), onStop, onDestroy. *Is anyone aware of this difference and why does that happen?* As a side note, this implies Binders should be passed around (in MainMenu) with care as they can go stale. Not really a big problem but something to keep in mind. I'm trying to devise a solution. For the time being, I'll think I'll resolve to 'instant service connections' so I bind, do what I need and unbind right away. I might do that in an AsyncTask in case... *isn't that an hammer solution?* I totally missed about this difference in documentation and I'm confused on how to use services correctly at this point. Elaborations are welcome. Massimo -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/b7a759ba-2013-4669-81c3-28628c12b59a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

