Use ActivityGroupas your class Activityand start and stop sub-actions for each type of map. For example, to get a view for Google Maps:
Intent intent = new Intent(this, GoogleMapActivity.class);
Window window = getLocalActivityManager().startActivity("google-map", intent);
View googleMapView = window.getDecorView();
container.addView(googleMapView);
to destroy it:
container.removeView(googleMapView);
getLocalActivityManager().removeAllActivities();
and do the same with your offline map. This should completely stop the MapActivitythreads.
Note that I found an LocalActivityManager.destroyActivity()error, so I used LocalActivityManager().removeAllActivities()in the example, since it works for this case.
source
share