在android位置管理器中,我们应该提供最小的更新距离变化和最小的更新间隔时间。因此,我需要知道我应该提供多长距离、最小距离范围和最短时间,以便尽快知道当前位置?
发布于 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应该是节省电池寿命的主要工具。
希望这能有所帮助。
https://stackoverflow.com/questions/17310430
复制相似问题