Android GPS如何跳过距离?

发布于 2024-10-05 02:23:08 字数 216 浏览 1 评论 0原文

我正在开发一个支持 GPS 的应用程序,我需要每 N 米记录一个点。但是,我看不到如何在 LocationListener 或任何其他方法/类中使用 onLocationChanged() 方法。 onLocationChanged() 方法每秒给出一个点,我需要存储每个 N 米的点。

我相信这有一个简单的解决方案,但由于我是 Android 初学者,找不到它。

任何帮助将不胜感激。

I am working on a GPS-enabled application and I need to record a point each N meters. However, I can't see how I can use onLocationChanged() method in the LocationListener or any other method/class. The onLocationChanged() method gives a point each second, and I need to store each N-meter point.

I believe that this has a simple solution, but since I am beginner in Android, cant find it.

Any help will be much appreciated.

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

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

发布评论

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

评论(3

夏了南城 2024-10-12 02:23:08

requestLocationUpdates 有一个 minDistance 参数,即
如果我没记错的话,可以做你想要的。不过我还没有在真机上进行过测试,所以我不知道它的准确性。

requestLocationUpdates has a minDistance parameter, that
if I recall correctly does what you want. I haven't been able to test this on a real phone though, so I don't know how accurate it is.

七分※倦醒 2024-10-12 02:23:08

onLocationChanged 中,将您获取的位置与您上次存储的位置进行比较。如果小于 n 米,则丢弃它。如果没有,请将其存储。冲洗。重复。

编辑:等等,更简单 - requestLocationUpdates 没有 minDistance 参数吗?请参阅此处: http://developer.android.com/reference/android/位置/LocationManager.html#requestLocationUpdates

In onLocationChanged, compare the location you get with the last one you stored. If it's less than n meters, discard it. If not, store it. Rinse. Repeat.

EDIT: Wait, even easier - doesn't requestLocationUpdates have a minDistance parameter? See here: http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates

不离久伴 2024-10-12 02:23:08

它工作得很好
myManager = ((LocationManager) ApplicationController.getAppContext().getSystemService( Context.LOCATION_SERVICE ));
myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1 * 1000, 0.00001f, this);

mintime =1000ms 总是在调用....

it is working perfectly
myManager = ((LocationManager) ApplicationController.getAppContext().getSystemService( Context.LOCATION_SERVICE ));
myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1 * 1000, 0.00001f, this);

mintime =1000ms always it is calling ....

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