glocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
glocListener = new MyLocationListenerGPS();
glocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
1000 * 1, // 1 Sec
1, // 1 meter
glocListener);
此代码用于使用GPS获取位置但当两个条件获得满意(1秒和1米)或仅一个时,它会更新位置吗?
答案 0 :(得分:1)
阅读javadoc,它说:
The minDistance parameter can also be used to control the frequency of location updates.
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
答案 1 :(得分:1)
正如Tooltip / Javadoc所说:
Parameters
provider the name of the provider with which to register
minTime minimum time interval between location updates, in milliseconds
minDistance minimum distance between location updates, in meters
让我们看看你的价值观:1s,1m:
如果最后一秒和现在之间的距离大于一米,则位置每秒更新一次
位置每米更新一次,如果最后一次更新是至少一秒钟。
TL; DR:这是AND,只有两者都是真的才会更新位置。