哪里是获取 GPS 数据的好地方?
我在我的 Android 应用程序中想要跟踪 GPS 信息并在所有活动中使用此信息。
在 Application 类中使用 onLocationChanged 是一个好方法吗?
我还想要一个计时器来测量经过的时间,并在所有应用程序中使用,而不仅仅是在一个 Activity 中使用
onLocationChanged 和计时器信息,并希望在我的应用程序中的所有活动中使用
功能不是问题,问题是我想要在我所有的 Android 应用程序中使用函数信息!
I in my android application I want to track GPS information and use this information 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您想创建一个 Android Service 来绑定您的 Android 应用程序。然后,您可以在服务中集中处理 GPS 位置更改和计时器内容。
您的任何活动都可以绑定到该服务并检索您需要的信息。
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.
正如codinguser所说,处理这个问题的正确方法是使用Android
Service
。我更喜欢使用
Broadcast
意图而不是绑定。从我的角度来看,这更容易。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.