diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index a12b5d6200b..2cae9ec17c3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -96,6 +96,7 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { private MapKeyListener mapKeyListener; private MapZoomButtonController mapZoomButtonController; private Bundle savedInstanceState; + private boolean isActivated; @UiThread public MapView(@NonNull Context context) { @@ -359,8 +360,11 @@ public void onSaveInstanceState(@NonNull Bundle outState) { */ @UiThread public void onStart() { - ConnectivityReceiver.instance(getContext()).activate(); - FileSource.getInstance(getContext()).activate(); + if (!isActivated) { + ConnectivityReceiver.instance(getContext()).activate(); + FileSource.getInstance(getContext()).activate(); + isActivated = true; + } if (mapboxMap != null) { mapboxMap.onStart(); } @@ -405,8 +409,11 @@ public void onStop() { mapRenderer.onStop(); } - ConnectivityReceiver.instance(getContext()).deactivate(); - FileSource.getInstance(getContext()).deactivate(); + if (isActivated) { + ConnectivityReceiver.instance(getContext()).deactivate(); + FileSource.getInstance(getContext()).deactivate(); + isActivated = false; + } } /** diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt index 66e205b8a43..d35c977df0d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/RecyclerViewActivity.kt @@ -120,7 +120,11 @@ class RecyclerViewActivity : AppCompatActivity() { } fun onDestroy() { - mapHolder?.mapView?.onDestroy() + mapHolder?.mapView?.let { + it.onPause() + it.onStop() + it.onDestroy() + } } class MapItem