0
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 米)或只有一个时它会更新位置?

4

2 回答 2

1

正如工具提示/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,如果两者都为真,则仅更新位置。

于 2013-07-12T10:13:17.720 回答
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

关联

于 2013-07-12T10:09:28.583 回答