I've already checked a bunch of other questions but none of the solutions have worked, I'm not using googleMap.setMyLocationEnabled(true) so thats not the problem.
The adapter that I am loading the MapView in is located here .
@Override
public void onMapReady(GoogleMap googleMap) {
//TODO: Allow user to update this 1-normal 2-satellite 3-Terrain
MapsInitializer.initialize(mContext);
gMap = googleMap;
gMap.getUiSettings().setAllGesturesEnabled(false);
googleMap.setMapType(1);
googleMap.getUiSettings().setMapToolbarEnabled(false);
// If we have map data, update the map content.
if (mMapLocation != null) {
updateMapContents();
}
}
The map loads fine and functions, I'm just getting Out of Memory errors after orientation changes.
Heres the output of LeakCanary:
In me.calebjones.spacelaunchnow.debug:1.0.0-DEBUG:28. * me.calebjones.spacelaunchnow.MainActivity has leaked: * GC ROOT maps.dz.af$af * references maps.dz.af.k * references maps.dg.p.mParent * references android.widget.FrameLayout.mParent * references com.google.android.gms.maps.MapView.mContext * leaks me.calebjones.spacelaunchnow.MainActivity instance
There are GoogleMap in your ViewHolder. You should override method onViewRecycled and clean memory:
@Override
public void onViewRecycled(FriendViewHolder holder) {
if (holder.gMap != null) {
holder.gMap.clear();
holder.gMap.setMapType(GoogleMap.MAP_TYPE_NONE);
}
}
您是否尝试将其添加到清单中的活动标签中?
android:configChanges="orientation|screenSize"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.