当我第一次加载我的应用程序时,mapActivity 正在调用并且我可以看到地图,现在当我关闭网络连接并再次打开时,更改屏幕并返回到 mapactivity 地图显示为 null,在这一行新MapUtils().drawMap(this);
出现nullpointer 异常onResume()
方法。
@Override
protected void onResume() {
Utils utils = new Utils();
manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
listener = new ManageLocation();
listener.setSucessCallBack(this, "setLocation");
listener.setFailureCallBack(this, "setNoLocation");
manager.requestLocationUpdates(
utils.getCurrentPlaceLocationProvider(manager), 0, 0,
listener);
super.onResume();
Log.d(TAG, "Constants.isDataLoadedPAB " + Constants.isMaptobeLoaded
+ " Constants.isDataLoadedPAB : " + Constants.isDataLoadedPAB);
if (Constants.isMaptobeLoaded) {
if (Constants.isDataLoadedPAB) {
try {
new MapUtils().drawMap(this);
} catch (Exception e) {
Log.e(TAG, "Error", e);
}
} else {
if (Constants.currentLocation != null
&& Constants.searchLocation != null) {
if (Constants.searchResultData == null) {
Constants.searchResultData = new ArrayList<AttractionData>();
}
new MapUtils().drawMap(this);
}
}
}
((ImageView) activity.findViewById(R.id.left)).setEnabled(true);
((ImageView) activity.findViewById(R.id.right)).setEnabled(true);
((ImageView) findViewById(R.id.searchicon)).setEnabled(true);
((ImageView) activity.findViewById(R.id.facebookintegration)).setEnabled(true);
}
我试图再次调用它,onResume()
但仍然为空。我很震惊,不确定我在哪里做错了。感谢任何帮助
我的日志
01-29 11:23:36.325: E/AndroidRuntime(6668): Caused by: java.lang.NullPointerException
01-29 11:23:36.325: E/AndroidRuntime(6668): at org.appright.myneighborhood.maps.MapUtils.drawMap(MapUtils.java:59)
01-29 11:23:36.325: E/AndroidRuntime(6668): at org.appright.myneighborhood.activity.CityAttractions.onResume(CityAttractions.java:505)
01-29 11:23:36.325: E/AndroidRuntime(6668): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1199)
01-29 11:23:36.325: E/AndroidRuntime(6668): at android.app.Activity.performResume(Activity.java:5280)
01-29 11:23:36.325: E/AndroidRuntime(6668): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2606)
01-29 11:23:36.325: E/AndroidRuntime(6668): ... 10 more