Fix crash when no gps coord

This commit is contained in:
Leith Bade
2014-11-23 22:16:29 +11:00
parent 0e13a5ab24
commit 51bcbbcc70

View File

@@ -79,8 +79,10 @@ public class MainActivity extends ActionBarActivity {
LocationManager locationManager = (LocationManager)getSystemService(getApplicationContext().LOCATION_SERVICE);
String provider = locationManager.getBestProvider(new Criteria(), true);
Location location = locationManager.getLastKnownLocation(provider);
LonLatZoom coordinate = new LonLatZoom(location.getLongitude(), location.getLatitude(), 15);
mMapFragment.getMap().setCenterCoordinate(coordinate, true);
if (location != null) {
LonLatZoom coordinate = new LonLatZoom(location.getLongitude(), location.getLatitude(), 15);
mMapFragment.getMap().setCenterCoordinate(coordinate, true);
}
locationManager.requestSingleUpdate(provider, new MyLocationListener(), null);
return true;