I have com.google.android.gms.maps.MapViewone that I create dynamically using
mapView = new MapView(DataManager.getInstance().getContext());
This mapView binds to the parent through addView(mapView). Somewhere later in my program I want to delete this mapView by calling parent.removeAllViews();, but there the android just nods. The application is completely frozen, and I have no idea why. What can I do to solve this problem?
Edit:
I did some more research using CustomMapView:
import android.content.Context;
import android.view.View;
import com.google.android.gms.maps.MapView;
public class CustomMapView extends MapView {
public CustomMapView(Context context) {
super(context);
}
@Override
public void onViewRemoved(View child) {
super.onViewRemoved(child);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
}
public void remove() {
onPause();
onDestroy();
}
}
remove , , . onPause , onDestroy . onCreate(), onResume(), . onDestroy() onPause() , removeView(child) . , , onPause . - , , , ?
:
, , public void onInfoWindowClick(final Marker marker) {. , runOnUiThread().