初始化映射到Fragment每个更改的屏幕都会占用双RAM

时间:2018-10-07 15:09:21

标签: java android google-maps android-fragments profiler

我将GoogleMap放入Fragment,并在onViewCreated中得到:

mapView.onCreate(savedInstanceState);
        mapView.onResume();
        mapView.getMapAsync(new OnMapReadyCallback() {
            @SuppressLint("MissingPermission")
            @Override
            public void onMapReady(GoogleMap googleMap) {
                mGoogleMap = googleMap;
                mGoogleMap.setMyLocationEnabled(true);
                LatLng myplace = new LatLng(00.0000, 00.0000);
                mGoogleMap.addMarker(new MarkerOptions().position(myplace).title("Title").snippet("Description"));
                CameraPosition cameraPosition = new CameraPosition.Builder().target(myplace).zoom(12).build();
                mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

            }
        });

现在每个方向都发生了变化,我在AndroidStudio中看到-旋转1圈后探查器140MB-210MB,接下来的250MB-350MB,最后设备出现黑屏并重置:)

如何优化呢?

0 个答案:

没有答案