/** Null out the static references when the MapView is detached to prevent memory leaks. */ @Override public void onDetach(MapView mapView) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { if (mIcon instanceof BitmapDrawable) { final Bitmap bitmap = ((BitmapDrawable) mIcon).getBitmap(); if (bitmap != null) { bitmap.recycle(); } } } mIcon = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { if (mImage instanceof BitmapDrawable) { final Bitmap bitmap = ((BitmapDrawable) mImage).getBitmap(); if (bitmap != null) { bitmap.recycle(); } } } cleanDefaults(); this.mOnMarkerClickListener = null; this.mOnMarkerDragListener = null; this.resource = null; setRelatedObject(null); closeInfoWindow(); onDestroy(); super.onDetach(mapView); }
/** Null out the static references when the MapView is detached to prevent memory leaks. */ @Override public void onDetach(MapView mapView) { mDefaultIcon = null; mDefaultInfoWindow = null; super.onDetach(mapView); }