The problem is with this line
FrameLayout topLayout = (FrameLayout) activity.findViewById(R.id.map_container);
topLayout.removeAllViews();
in MapUtils().drawMap(this);
what you are doing is to remove all the view from container i.e. FrameLayout map_container
when network connection
not available.
And when network comes again you are accessing the MapView
which you have removed from the layout hierarchy and it wont find the defaultmapView
this time and throw NullPionterException
.
Try to comment all the code in else
block and just show a toast only. hope it will work. Or try some different logic.