我一直在尝试查找每 5 分钟获得的位置GPS_Provider
以及Network_Provider
在任何特定时间获得的两个值的同一时间戳。
我尝试使用以下给定的位置策略
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Define a listener that responds to location updates
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found by the network location provider.
makeUseOfNewLocation(location);
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
// Register the listener with the Location Manager to receive location updates
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 300000, 0, locationListener)
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,300000, 0, locationListener)
但是onLocationChanged()
如果自上次位置更新以来的时间大于notificationInterval
.
GPS_Provider
这给我带来了每 5 分钟和之后生成的值之间的一些时间戳差异Network_Provider
。有什么方法可以让我找到GPS_Provider
并Network_Provider
在同一时间戳生成的位置。
例子:
现在:GPS_Provider
(lat,long) at 09:35:12 , Network_Provider
(lat,long) at 09:35:14
我需要:GPS_Provider
(lat,long) at 09:35:12 , Network_Provider
(lat,long) at 09:35:12