我正在使用此代碼設置地圖的中心。在Android中使用MapController的setCenter方法時出現空指針異常
mapController.setCenter(new GeoPoint((int)(location.getLatitude()*1E6), (int) (location.getLongitude()*1E6)));
其中作爲
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);
我得到這個代碼空指針異常位置定義。我究竟做錯了什麼?
NPE上線是什麼? – Tnem 2011-05-20 13:30:08
mapController.setCenter行 – 2011-05-20 18:36:37