I have been trying to find the location obtained by GPS_Provider
and Network_Provider
for every 5 minutes and at the same time stamp for the two values obtained at any specific time.
I tried using the following location strategy given
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)
But here the Location Manager will call the onLocationChanged()
method of the listener if the time since last location update is greater than the notificationInterval
.
This brings me some time stamp difference between values generated by GPS_Provider
and Network_Provider
after every 5 minutes.Is there any way such that I can find the location that GPS_Provider
and Network_Provider
generate at a same time stamp.
Example:
Now: GPS_Provider
(lat,long) at 09:35:12 , Network_Provider
(lat,long) at 09:35:14
I need: GPS_Provider
(lat,long) at 09:35:12 , Network_Provider
(lat,long) at 09:35:12