Mike: I DO need it to run in the background, that is, while orientation is changing. The service is also really nice because I can do things like submit a score in the background while the user is going from the game back to the game menu. I don't like the static handler idea because it can't have more advanced capabilities like the queue my service has. Basically my service guarantees that the network request will finish and the response will be available to the next registered callback handler. I really like that.
I know it's more complicated but my app feels really nice and polished now. Streets of Boston: Each bind is prefaced with a startService. This ensures that the service will be running and will continue to run after the unbind. The service is smart and shuts itself down so this approach works perfectly for me. If a rebind happens 30 seconds later, the service will just start back up in persistent-run-mode like always because startService will have been called. Since the really important stuff always happens within a few seconds of an unbind, the restarting later doesn't matter at all. Also, it will never restart while a user is in an activity because the activity binds onResume and unbinds onPause, so it remains bound the entire time it is visible. I think the way I did it is responsible because the service is always available when needed but doesn't stick around more than 30 seconds longer than the user was last in the app. I'm sure there are other ways but this is coded, well-tested and on the market so I'm not changing it anytime soon :) On May 29, 10:43 am, Mike Hearn <mh.in.engl...@gmail.com> wrote: > > Done! Man I'm happy to have that working. I've been retrofitting all > > the netcode with this service for the past 20 hours of coding and I > > can't wait to not be working on this anymore! > > Well, I did show you a simpler way to do it. I'm not sure you should > write a tutorial on this - like I said, it's a lot more complicated > than is necessary. You only need a service if you want to run in the > background when your activities aren't on-screen, which it sounds like > isn't warranted here. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---