I in my android application I want to track GPS information and use this i开发者_开发技巧nformation in all activity.
Is it a good way to use onLocationChanged, in the Application class?
I also want to have a timer that will measure the elapsed time, and use in all applications not only in one Activity
The information onLocationChanged and timer and want to use in all activities in my application
Functions are not problem, problem is that I want to use function information in all my android application!
maybe you want to create an Android Service to which your Android applications bind. Then you can handle the GPS location change and the timer stuff centrally in the service.
Any of your Activities can bind to the service and retrieve the info you need.
As codinguser said, the correct way to handle this is using an Android Service
.
I would prefer using a Broadcast
intent instead of binding. From my point of view, it's easier.
精彩评论