有什么方法可以在 Android 中获得快速(5 毫秒)位置更新? [英] Is there any way to get Fast (5 milliseconds) location updates in Android..?

查看:45
本文介绍了有什么方法可以在 Android 中获得快速(5 毫秒)位置更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 android 中使用 Fused Location Provider 库.它工作得很好.但我遇到了问题,它会在 最少 5 秒 内返回位置更新.

I'm using Fused Location Provider library in android. It is working perfectly fine. But I've an issue with it, it returns location updates in 5 sec minimum.

我尝试了所有事情,例如将最小更新时间设置为 1 毫秒,将距离设置为 0.01 米,将优先级设置为 PRIORITY_HIGH_ACCURACY

I've tried every thing like setting minimum updates time to 1 millisecond, and distance to 0.01 meter and Priority to PRIORITY_HIGH_ACCURACY

我的代码:

locationrequest.setInterval(1);//1 毫秒locationrequest.setSmallestDisplacement(0.01f);//0.01 米 locationrequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);

但没有用,两次连续位置更新之间的最短时间仍然是5 秒.

But no use, still minimum time between two successive location updates is 5 seconds.

我的问题是:有没有办法将位置更新时间减少到5毫秒?

My Questions is : Is there any way to decrease location updates time to 5 milliSeconds ?

-> 我只需要10 分钟的位置更新,所以电池消耗高没有问题.

-> I need location updates for only 10 minutes, So no issue with the high battery consumption.

-> 我需要任何方式(可能):是否有任何外部硬件可用,通过蓝牙连接并将位置更新发送到该级别?

-> I need any way (possible): Is there any external hardware available, which connects via Bluetooth and send location updates upto that level ?

让我问你一个不同的问题:位置更新的最短时间是多少?如何实现?

Let me ask you a different question : What can be the minimum possible time for location updates and how to achieve that ?

假设我想跟踪一辆以 400 公里/小时的速度行驶的汽车,这意味着在大约 50 毫秒5 米.那么你能提出更好的方法来追踪这辆车吗?

Let's say i want to track a car, which is moving with the speed of 400 KM/h, means 5 meter in about 50ms. So can you suggest any better way to track this car ?

推荐答案

位置感应硬件(GPS、AGPS 等)的精确度和准确性意味着比每隔几秒更频繁地获取更新不太可能提供有意义的结果.事实上,像 Fused Location Provider 这样的技术可能会优先获得更准确的结果,而不是每几百毫秒提供一次结果.

The precision and accuracy of location-sensing hardware (GPS, AGPS, etc.) means that getting updates more frequently than every few seconds isn't likely to provide meaningful results. In fact, technology like the Fused Location Provider is likely to prioritize getting more accurate results rather than providing results every few hundred milliseconds.

除此之外,每秒多次更新所消耗的电池电量可能非常大.

In addition to that, the battery drain from getting updates multiple times a second is likely to be very significant.

说了这么多.获取位置感应硬件收到的每次更新的方法是将位置更新间隔和最小位移设置为零,并优先考虑准确性.

All that said. The way to get every update that your location-sensing hardware is receiving is to set the location update interval and minimum displacement to zero, and to prioritize accuracy.

locationrequest.setInterval(0); // No delay.
// locationrequest.setSmallestDisplacement(0); // This is the default.
locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

请注意,这将为您提供每次更新,但根据硬件限制以及可能的 Fused Location Provider 实现,无法保证这会比您目前发现的 5s 频率快.

Note that this will give you every update, but depending on the hardware limitations, and potentially the Fused Location Provider implementation, there's no guarantee this will be any faster than the 5s frequency you've found so far.

这篇关于有什么方法可以在 Android 中获得快速(5 毫秒)位置更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆