Android Location Error
Posted
by Christopher
on Stack Overflow
See other posts from Stack Overflow
or by Christopher
Published on 2010-04-26T04:22:33Z
Indexed on
2010/04/26
4:33 UTC
Read the original article
Hit count: 421
I've singled out my problem to a few lines of code
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 5.0f, this);
lat = location.getLatitude();
lng = location.getLongitude();
//lat = new Double(40.431682);
//lng = new Double(-74.2021819);
pLocation = new GeoPoint((int)(lat * 1000000), (int)(lng * 1000000));
My onLocationChanged if you were wondering
public void onLocationChanged(Location location) {
if (location != null) {
lat = location.getLatitude();
lng = location.getLongitude();
pLocation = new GeoPoint((int)(lat * 1000000), (int)(lng * 1000000));
}
}
My application crashes if I try to get the LastKnownLocation
But it works fine if I feed it a Location manually
I have no idea currently whats wrong
© Stack Overflow or respective owner