Android GPS定位仪
此代码用于使用GPS获取位置,但当两个条件都满足(1秒和1米)或仅满足一个条件时,它将更新位置?阅读javadoc,它说:Android GPS定位仪,android,android-location,Android,Android Location,此代码用于使用GPS获取位置,但当两个条件都满足(1秒和1米)或仅满足一个条件时,它将更新位置?阅读javadoc,它说: glocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); glocListener = new MyLocationListenerGPS(); glocManager.requestLocationUpdates(LocationManager.G
glocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
glocListener = new MyLocationListenerGPS();
glocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
1000 * 1, // 1 Sec
1, // 1 meter
glocListener);
正如工具提示/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米:如果上一秒到现在的距离大于一米,则位置每秒更新一次。
如果上次更新至少在一秒钟前,则位置每米更新一次
TL;医生:而且,只有当两者都是真的时,位置才会更新。这意味着当双方都满意时,我才会得到更新
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