Ryan
Ryan

Reputation: 161

GPS emulator tracks

I am using the android emulator ddms to simulate movement using a gpx file. There are about 1000 entries in the gpx file. However, I'm finding that my onLocationChanged method is only being triggered a few times during the course of the entire file. My code is as follows...

LocationManager locationManager = (LocationManager)    this.getSystemService(Context.LOCATION_SERVICE);         

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, myListener);

myListener = new LocationListener(){
public void onLocationChanged(Location location){
    double mylat = location.getLatitude();
    double mylon = location.getLongitude();  
    ...
    }
...
}

My understanding of the requestLocationUpdates being set to 1000 is that it should request a location update every 1 second provided the location is more than 1m away from the previous. Is this correct? If so, why would I only be retrieving a few of the lat/lon pairs from the gpx file? Wouldn't I be retrieving nearly a thousand? (The GPS data is from someone running so there is constant motion.)

Upvotes: 0

Views: 580

Answers (1)

Marc Bernstein
Marc Bernstein

Reputation: 11511

I haven't had very good luck with using the emulator locations using gpx, kml, or manually entering lat/long coordinates . In my experience, setting the location and distance minimums in requestLocationUpdates does work well on real hardware but not in the emulator.

If using the gpx file is just for testing purposes, try setting the time and location constraints to 0 and 0 just to see if it now registers all 1000 of your points within the emulator.

Upvotes: 1

Related Questions