0

I want to implement my GPS listener at the Application class level of my Android project, since the project includes a few different Activities that use GPS data (and different developers building those Activities...)

The problem is, the Application Class doesn't have an opposite to its onCreate() method (It does have onTerminate(), but that's completely fake), so I'm unable to implement my code to stop the listener (locSvc.removeUpdates (gpsReader);) -- After I exit the application, the GPS happily runs along eating charge...

Does anyone have a suggestion for a GPS listener interface that can detect when its "parent" listener has gone away and kill itself?? I'm not seeing a notice of a NullPointerException on the screen or in logcat, but might that work??

Thanks, R.

Rich
  • 4,157
  • 5
  • 33
  • 45

1 Answers1

1

You should run if from a Service that each Activity can bind to.

techi.services
  • 8,473
  • 4
  • 39
  • 42
  • Fair enough, could you point me to a Service example? I've never built one. Also, should I start/stop service in every Activity?? – Rich May 17 '12 at 17:18
  • Have a look here for the Dev Guide http://developer.android.com/guide/topics/fundamentals/services.html. – techi.services May 17 '12 at 17:22