I have this bit of code;
lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
gpslocation = Double.toString(lm.getLastKnownLocation("gps").getLatitude()) +" "
+ Double.toString(lm.getLastKnownLocation("gps").getLongitude());
Which works fine on both the emulator and my hero running android 1.5, but it Force Closes on the emulator of 1.6 and also on my tattoo.
What changed from 1.5 to 1.6?
OK, using this instead;
lm = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
Double latPoint = null;
Double lngPoint = null;
Location loc = lm.getLastKnownLocation("gps");
if(loc != null) {
latPoint = lm.getLastKnownLocation("gps").getLatitude();
lngPoint = lm.getLastKnownLocation("gps").getLongitude();
} else {
}
Toast.makeText(getBaseContext(),"test lat " + latPoint, Toast.LENGTH_LONG).show();
I get null toast, and null toast if i fire a location at the emulator before running the app.