installComponents

Install UI components in the default MapboxNavigation instance.

Each component will be attached to the default MapboxNavigation instance on lifecycleOwner event and detached on Lifecycle.Event.ON_DESTROY.

Example usage:

class MyNavigationActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.my_nav_activity)

        // ...

        val soundButton = findViewById<MapboxAudioGuidanceButton>(R.id.soundButton)
        val mapView = findViewById<MapView>(R.id.mapView)

        MapboxNavigationApp.installComponents(this) {
            audioGuidanceButton(soundButton)
            routeLine(mapView)
            routeArrow(mapView)

            component(MyCustomUIComponent())
        }
    }
}

Install UI components in receiving MapboxNavigation instance.

Each component will be attached to receiving MapboxNavigation instance on lifecycleOwner event and detached on Lifecycle.Event.ON_DESTROY.

Example usage:

class MyNavigationActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.my_nav_activity)

        // ...

        val soundButton = findViewById<MapboxAudioGuidanceButton>(R.id.soundButton)
        val mapView = findViewById<MapView>(R.id.mapView)

        val mapboxNavigation = MapboxNavigationProvider.retrieve()
        mapboxNavigation.installComponents(this) {
            audioGuidanceButton(soundButton)
            routeLine(mapView)
            routeArrow(mapView)

            component(MyCustomUIComponent())
        }
    }
}