You can change the minimum distance when you call requestLocationUpdates method.
locmgr.requestLocationUpdates(locmgr.GPS_PROVIDER, 10, 2, gpsListener);
Here is the explenation.
Pregunta
I'm using an application that uses the gps feature (using AVD on Eclipse). This application works fine when i put the coordinates with the DDMS, but if I insert a point that is very close to the previous point (20-30m), the onLocationChanged(Location loc)
event is not called (but the application doesn't crash. If I insert a new point that is not so close, the even is correctly called). Is this an emulator's problem? Or is it a problem caused by the requestLocationUpdates(...)
method? My code is this:
public class myActivity extends Activity
{
private TextView mytext;
private LocationManager locmgr = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GPSListener gpsListener=newGPSListener();
mytext = (TextView) findViewById(R.id.mytext);
//grab the location manager service
locmgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locmgr.requestLocationUpdates(locmgr.GPS_PROVIDER, 10, 10, gpsListener);
mytext.setText("waiting for location");
}
//Start a location listener
private class GPSListener implements LocationListener
{
public void onLocationChanged(Location loc)
{
//sets and displays the lat/long when a location is provided
String latlong = "Lat: " + loc.getLatitude() + " Long: " + loc.getLongitude();
mytext.setText(latlong);
}
public void onProviderDisabled(String provider)
{
}
public void onProviderEnabled(String provider)
{
}
public void onStatusChanged(String provider, int status,
Bundle extras)
{
}
}
}
Solución
You can change the minimum distance when you call requestLocationUpdates method.
locmgr.requestLocationUpdates(locmgr.GPS_PROVIDER, 10, 2, gpsListener);
Here is the explenation.
Otros consejos
I think this is correct behaviour due to GPS precision. In other words 20-30m from current point is the same position from GPS's point of view