同一项目的两个类中的两个 LocationListener

发布于 2024-12-09 04:24:40 字数 900 浏览 5 评论 0原文

我正在使用 AR Kit 开发 Android 2.2 应用程序(您可以在此处找到它)。

该套件是一个 eclipse 项目,有两个监听 GPS 接收器的类。

这些类是 ARLayout.java (视图)和 HoldMeUp.java(主要活动)。

我发现 ARLayout.java 需要使用 GPS 位置更新其数据,因此它实现了 LocationListener。

HoldMeUp也需要使用GPS定位,因此它有一个LocationListener。

我正在更新 HoldMeUp,以便在应用程序进入暂停状态时关闭 GPS。我可以停止 HoldMeUp LocationListener,但无法停止 ARLayour LocationListener。

我对此有一些疑问:

  1. 是否有必要有两个 LocationListener?
  2. 我可以在 HoldMeUp 对象上只拥有一个吗? ARLayout 添加到 FrameLayout,该 FrameLayout 设置为 HoldMeUp 的 ContentView。
  3. 如何从 HoldMeUp 将位置更新为 ARLayout?

I'm developing an Android 2.2 app using an AR Kit (you can find it here).

This KIT is an eclipse project that has two classes that listenning to GPS RECEIVER.

These classes are ARLayout.java (a View) and HoldMeUp.java (Main Activity).

I've seen that ARLayout.java needs to update its data using GPS location, so it implements LocationListener.

HoldMeUp also needs to use GPS location, so it has a LocationListener.

I'm updating HoldMeUp to swith off GPS when app goes onPause. I can stop HoldMeUp LocationListener, but I can't stop ARLayour LocationListener.

I have some questions about it:

  1. Is it necessary to have two LocationListener?
  2. Could I have only one on HoldMeUp object? ARLayout is added to a FrameLayout, that is set as ContentView for HoldMeUp.
  3. How can I update location to ARLayout from HoldMeUp?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

[旋木] 2024-12-16 04:24:40

问:以上指定班级是否同时使用 GPS?
如果是,那么您应该创建一个 ARLayout 类的对象并定义一些公共方法,例如 public void UpdateGPSState(GPS Paremeters) 并从主活动的 onLocationChangeListner 或其他位置列表函数中调用它。
一旦主要活动有更新,您的函数调用将自动更新 ARLayout 的 GPS 要求。

Q. Do above specified classes use GPS simultaneously?
If yes then you should create an object of ARLayout class and define some public method like public void UpdateGPSState(GPS Paremeters) and call it from main activity's onLocationChangeListner or other Location Listner Functions..
Once there is an update in main activity your function call will automatically update ARLayout's GPS requirements.

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