【发布时间】:2016-06-24 10:46:32
【问题描述】:
我正面临 OOM 问题,因为 supportMapFragment 没有被破坏。
使用的Xml:
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
代码 sn-p:
mMapFragment = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map));
GoogleMapOptions mapOptions = new GoogleMapOptions();
mapOptions.useViewLifecycleInFragment(true);
mMapFragment.newInstance(mapOptions);
//ondestroy调用
@Override
protected void onDestroy() {
super.onDestroy();
//clear all the data
mMap.clear();
mMapFragment.onDestroyView();
}
遵循与给定文档中提到的相同: https://developers.google.com/android/reference/com/google/android/gms/maps/SupportMapFragment
【问题讨论】:
-
问题是,
onDestroy()可能不会被调用 - 不能保证它会被调用。 -
在销毁活动时调用检查部分..
标签: android google-maps-android-api-2 markerclusterer