i am getting different Gps coordinates in same location why its happening. But i need to change gps coordinates only moves after 10 meters . How can i do that.
Here is my code.
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000;
private static final float MIN_GEOGRAPHIC_POOLING_DISTANCE = (float)10.0;
double myLat_Values;
double myLog_Vaues;
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MIN_GEOGRAPHIC_POOLING_DISTANCE, new MyLocationListener());
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location location) {
longitude_str = String.valueOf(location.getLongitude());
latitude_str = String.valueOf(location.getLatitude());
Double longitude_number = Double.valueOf(longitude_str);
DecimalFormat dec = new DecimalFormat("#.000000");
longitude_message = dec.format(longitude_number);
Double latitude_number = Double.valueOf(latitude_str);
DecimalFormat decim = new DecimalFormat("#.000000");
latitude_message = decim.format(latitude_number);
try
{
myLat_Values = Double.valueOf(latitude_message);
myLog_Vaues = Double.valueOf(longitude_message);
}
catch(NullPointerException ex)
{
myLat_Values = 0;
myLog_Vaues = 0;
}
System.out.println("GPS Values Clockout:"+myLat_Values+"-"+myLog_Vaues);
}
public void onProviderDisabled(String s) {}
@Override
public void onProviderEnabled(String provider) {}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {}
}
also i used these into manifestfile :
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
I used this link
please anybody give a suggestion how to solve my problem.
Thank you in advanced.
When you use NETWORK_PROVIDER ,it returns GPS co-ordinates based on the Network Service Provider you are using. But when you are using GPS_PROVIDER it returns GPS co-ordinates based on the satelites.
For Accuracy Criteria, add following code,
Also, you need to declare following GPS Permission in AndroidManifest.xml