I'm trying to get gps postion as precise as posible at different interval ranges, i have few external gps, 10hz, 5hz and 1hz
LocationManager locationManager = (LocationManager)
car.this.getSystemService(car.this.LOCATION_SERVICE);
LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
// Called when a new location is found
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
locationListener);
With this way i get a log update like this while driving at constant speed
10hz GPS
81ms new position
79ms new position
88ms new position
96ms new position
196ms new positon
60ms new positon
256ms new position
70ms new position
5 hz GPS
187ms new...
189ms ..
275ms ..
140ms ..
180ms ..
220ms ..
So i think onStatusChanged is initially faster than the nominal frequency but then saturates and causes bigs jumps
If i use a timer, it's works well and i get position each 100ms (200 or 1000) but the timer goes off around 100ms each 10 seconds
Edit: For clarify, i want to get a position each exact (or near) 100ms,200ms or 1000ms
**UPDATE 12-04-13
After redone my code to work with location.getTime() this are the results, all test were made at outside, at mid/hight speed and logging during 10 minutes for each device
HTC Sensation Z710e 4.0.3 Internal GPS 1HZ
Average Accuracy: 12.1m
Average intertval: 1186ms
Min: 98ms
Max: 2621ms
HTC Desire HD 4.0.4 Internal GPS 1HZ
Average Accuracy: 10.6m
Average intertval: 1211ms
Min: 144ms
Max: 2588ms
ASUS Transformer TF101 4.0.4 Internal GPS 1HZ
Average Accuracy: 18.15m
Average intertval: 1000MS
Min: 1000ms
Max: 1000ms
SAMSUNG NOTE II GT-N7100 4.1.2 Internal GPS 1HZ (Glonass)
Average Accuracy: 6.8m
Average intertval: 1000MS
Min: 1000ms
Max: 1001ms
SAMSUNG, HTC OR ASUS with external GPS 5HZ
Average Accuracy: 2.2m
Average intertval: 200MS
Min: 200ms
Max: 200ms
SAMSUNG, HTC OR ASUS with external GPS 10HZ (Glonass)
Average Accuracy: 1.6m
Average intertval: 100MS
Min: 100ms
Max: 100ms
Dont look at the (system) timestamp when you received the location, look at the timestamp of the location itself, if it is delivered by GPS it should be exactly 1000ms (1/hz).
Gps receivers never deliver odd milliseconds, they are exactly at millisecond 1000, when using 1hz. use location.getTime(), and see yourself.
There is no such thing as a precise time interval in a virtualized, multi-threaded application. You will get notifications when the OS gets around to running your thread, whether you use a timer or not.