I’m using this code to set the center of the map.
mapController.setCenter(new GeoPoint((int)(location.getLatitude()*1E6), (int) (location.getLongitude()*1E6)));
where location is defined as
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);
I get a null pointer exception with this code. What am I doing wrong?
You are probably getting a null response from locationManager.getLastKnownLocation(provider);
http://developer.android.com/reference/android/location/LocationManager.html#getLastKnownLocation%28java.lang.String%29