我已经设置了LocationManager以每2分钟获取当前位置:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,120000,this);
这工作正常,onLocationChanged按预期每2分钟调用一次.然而,似乎每2分钟在10-40(随机量)第二跨度上多次调用它.我记录了onLocationChanged中收到的每个位置,所以这里有一些示例来了解发生了什么:
17:30
GPS 32.0 50.66318929195404 10.735434293746948 0.0 2010.08.07 17:30:10 GPS 32.0 50.66315710544586 10.735423564910889 0.0 2010.08.07 17:30:14 GPS 32.0 50.66314101219177 10.735418200492859 0.0 2010.08.07 17:30:17 GPS 32.0 50.66314101219177 10.735418200492859 0.0 2010.08.07 17:30:20 GPS 24.0 50.66313564777374 10.735418200492859 0.5 2010.08.07 17:30:24 GPS 32.0 50.663098096847534 10.735573768615723 0.0 2010.08.07 17:30:28 GPS 32.0 50.663065910339355 10.735611319541931 0.0 2010.08.07 17:30:31
然后我在2分钟内没有更新.
17:32
GPS 32.0 50.661821365356445 10.737022161483765 1.0 2010.08.07 17:32:39 GPS 16.0 50.66170871257782 10.737043619155884 1.8200275 2010.08.07 17:32:45 GPS 24.0 50.661579966545105 10.737027525901794 1.25 2010.08.07 17:32:50 GPS 16.0 50.66150486469269 10.73712408542633 1.0 2010.08.07 17:32:55 GPS 12.0 50.661579966545105 10.73715090751648 0.9013878 2010.08.07 17:33:01 GPS 24.0 50.66139221191406 10.737038254737854 1.5811388 2010.08.07 17:33:06 GPS 16.0 50.66141366958618 10.737301111221313 0.70710677 2010.08.07 17:33:12 GPS 16.0 50.66141366958618 10.737301111221313 0.70710677 2010.08.07 17:33:12 GPS 24.0 50.661311745643616 10.737070441246033 1.118034 2010.08.07 17:33:16 GPS 16.0 50.66122591495514 10.737177729606628 1.118034 2010.08.07 17:33:22 GPS 12.0 50.66124200820923 10.737220644950867 1.3462912 2010.08.07 17:33:26 GPS 12.0 50.661311745643616 10.737268924713135 3.6055512 2010.08.07 17:33:25
等等……然后在2分钟后的17:35进行另一组更新.
这是标准行为吗?我期望每2分钟只获得一个位置,并且它给我位置更新的时间跨度似乎相当随机.理想情况下,我宁愿只获得一个位置……有没有办法做到这一点?