首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >android locationmanager应该提供多长的最小距离?

android locationmanager应该提供多长的最小距离?
EN

Stack Overflow用户
提问于 2013-06-26 10:05:21
回答 1查看 4.3K关注 0票数 1

在android位置管理器中,我们应该提供最小的更新距离变化和最小的更新间隔时间。因此,我需要知道我应该提供多长距离、最小距离范围和最短时间,以便尽快知道当前位置?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-26 10:34:52

虽然将这两个值都设置为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 or greater. If your application is in the and showing location to the user then it is appropriate to select a faster update interval

就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应该是节省电池寿命的主要工具。

希望这能有所帮助。

票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17310430

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档