哪里是获取 GPS 数据的好地方?

发布于 2024-09-16 09:20:36 字数 264 浏览 2 评论 0原文

我在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陪你到最终 2024-09-23 09:20:36

也许您想创建一个 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.

感性不性感 2024-09-23 09:20:36

正如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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文