Hi I am working on a app and i need to fetch the exact (accurate,to the extent) latitude and longitude. The method i used is LocationListener but the issue is, each and every time i am getting different numbers for the same location - say almost a variance of 800 meters.Is there a way i can get the exact numbers each and every time? Below is the code. Please help me in this
public Location getlocation(){
if(ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
Toast.makeText(context,"Permission Not Granted",Toast.LENGTH_LONG).show();
return null;
}
LocationManager lm = (LocationManager) context.getSystemService(context.LOCATION_SERVICE);
boolean isGPSenabled=lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
if (isGPSenabled){
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,1,this);
Location l = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
return l;
}
else {
Toast.makeText(context,"Please Enable GPS",Toast.LENGTH_LONG).show();
}
return null;
}