when i first load my app mapActivity is invoking and i can see the map, now when i
switch off the networkconnectivity and on again , changing the screen and coming back
to the mapactivity the map is showing null, getting nullpointer exception at this
line new MapUtils().drawMap(this);
in onResume()
method.
@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);
}
I am trying to invoke it again in onResume()
but still getting null.
i am struck not sure where i am doing wrong.Any help is appreciated
my log
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