应该为android locationmanager提供多长的最小距离?
Posted
技术标签:
【中文标题】应该为android locationmanager提供多长的最小距离?【英文标题】:how long minimum distance should provide for android locationmanager? 【发布时间】:2013-06-26 02:05:20 【问题描述】:在 android 位置管理器中,我们应该提供更新的最小距离变化和更新之间的最短时间。因此,我需要知道我应该提供多长的最短距离范围和最短时间才能尽快知道当前位置?
【问题讨论】:
0 和 0 会破坏内存问题吗? 【参考方案1】:虽然将这两个值都设置为 0 会给您带来最快的速度,但会消耗大量资源,因此会损失大量电池电量。如文档所述,要选择合适的值,您必须首先查看您的需求:
The location update interval can be controlled using the minTime parameter. The elapsed time between location updates will never be less than minTime, although it can be more depending on the Location Provider implementation and the update interval requested by other applications.
此外,requestLocationUpdate
的 documentation 函数建议按如下方式选择您的值:
上面写着:
Choosing a sensible value for minTime is important to conserve battery life. Each location update requires power from GPS, WIFI, Cell and other radios. Select a minTime value as high as possible while still providing a reasonable user experience.
具体来说:
If your application is not in the foreground and showing location to the user then your application should avoid using an active provider (such as NETWORK_PROVIDER or GPS_PROVIDER), but if you insist then select a minTime of
5 * 60 * 1000(5 分钟) or greater. If your application is in the
前景 and showing location to the user then it is appropriate to select a
更新间隔更快。
就 minDistance 参数而言:
If it is greater than 0 then the location provider will only send your application an update when the location has changed by at least minDistance meters, AND at least minTime milliseconds have passed.
但是位置提供者使用 minDistance 参数更难节省电量,因此 minTime 应该是节省电池寿命的主要工具。
希望这会有所帮助。
【讨论】:
以上是关于应该为android locationmanager提供多长的最小距离?的主要内容,如果未能解决你的问题,请参考以下文章
android -LocationManager 为纬度和经度返回 0.0
Android 如何在 LocationManager 中获取高度。我总是归零
.isProviderEnabled(LocationManager.NETWORK_PROVIDER) 在 Android 中始终为真
LocationManager:是不是始终启用“网络”提供程序?
Android:isProviderEnabled(LocationManager.NETWORK_PROVIDER) 不起作用。只有 isProviderEnabled(LocationManage