Interface MapViewLifecycleListener
Interface MapViewLifecycleListener
-
public interface MapViewLifecycleListenerProvides a mechanism for observing a lifecycle of a map view and/or implementing components whose lifecycle needs to be linked with that of a map view.
A configuration change that results in
Activitybeing recreated does not trigger anonDestroy()call. The listener will be preserved throughout the destruction and recreation of the MapView. It is safe to hold and use theMapViewBaseobject passed inonAttach(com.here.sdk.mapview.MapViewBase)untilonDetach()oronDestroy()gets called. However, it is important that the listener does not hold a strong reference to anActivity, directly or indirectly (for example by holding a reference to aMapView. A component implementing this interface should interact with the map view only through theMapViewBaseobject passed inonAttach(com.here.sdk.mapview.MapViewBase).A
MapViewis using a SurfaceViewto render its content.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidonAttach(MapViewBase mapView)Called when addingMapViewLifecycleListenerto the map view.voidonDestroy()Called when the map view to which this is attached to is destroyed.voidonDetach(MapViewBase mapView)Called when removingMapViewLifecycleListenerfrom the map view.voidonPause()Called when the map view to which thisMapViewLifecycleListeneris attached to gets paused (usually when the app goes into background).voidonResume()Called when the map view to which thisMapViewLifecycleListeneris attached to gets resumed (usually when the app goes into foreground).
-
-
-
Method Detail
-
onAttach
void onAttach(@NonNull MapViewBase mapView)Called when adding
MapViewLifecycleListenerto the map view. If the map view does not have render target attached at the time of adding the listener, then this method will be called later, after render target is attached. This means that the map view it receives is always fully initialized.Can be used to implement the logic to create and add visual components to the map view.
- Parameters:
mapView-The map view to attach to.
-
onDetach
void onDetach(@NonNull MapViewBase mapView)Called when removing
MapViewLifecycleListenerfrom the map view. Can be used to implement the logic to remove visual components from the map view and release resources if necessary.- Parameters:
mapView-The map view to detach from.
-
onPause
void onPause()
Called when the map view to which this
MapViewLifecycleListeneris attached to gets paused (usually when the app goes into background). This should be used by components that perform continuous updates to pause those updates untilonResume()is called.
-
onResume
void onResume()
Called when the map view to which this
MapViewLifecycleListeneris attached to gets resumed (usually when the app goes into foreground). This should be used by components that perform continuous updates to resume those updates after a previous call toonPause().
-
onDestroy
void onDestroy()
Called when the map view to which this is attached to is destroyed. After this is called, no other
MapViewLifecycleListenermethod will be invoked. This should be used to make sure all resources are freed.
-
-