On Thu, Apr 28, 2011 at 3:31 PM, Eric <[email protected]> wrote: > How do you handle when user hits the HOME button, user leaves the app, > Android kills the process, and they return back into that Activity? >
That is why all activities that are using the service must at the least support the case where they bind and won't have access to the service until some time later when the connection is established. > In addition, my app has a large volume of data displayed in many > Activities, not just one set of server data / one Activity. > Another way you can approach this is to have a singleton that arbitrates access to the service -- it binds through the application context, and has a reference count of the current activities using it, to know when to unbind. (If you care about unbinding, you very well may not.) Then each activity gets this singleton, sets a callback, and update its UI when receiving the callback. If the singleton is already bound to the service, it performs the callback immediately. Using a singleton may be useful if there is common data being pulled out of the service and shared between activities. Then if Activity A has done something to pull some data out and launches Activity B, B can immediately get that same data without going through the service. Of course if you are following the local service sample, the singleton doesn't really add a whole lot since the service itself can store all of this data in itself with the same rich Java API to access it. The singleton approach may still be something you like better than using a common activity base class, depending on your preference. -- 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

