My Android program using GPS is very inaccurate
-
29-10-2019 - |
문제
I have made a program using GPS and its Latitude and Longitude are about 8 miles off.
I thought it may be because I am inside but when I use google maps on my phone, it shows me at my house.
Any idea why this may be?
Code below:
public class Clue extends Activity {
public static double latitude;
public static double longitude;
LocationManager lm;
LocationListener ll;
Location location;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.blah);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll = new MyLocationListener()}
private boolean getLoc() {
location = getLocation();
longitude = location.getLongitude();
latitude = location.getLatitude();
return inCorrectPlace(params);
}
private Location getLocation() {
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
return lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}
}
I have stripped out irrelevant code, all help will be appreciated.
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow