Reputation: 4207
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.
Upvotes: 0
Views: 732
Reputation: 8533
You should run if from a Service
that each Activity
can bind to.
Upvotes: 1