Mapbox Navigation App
object MapboxNavigationApp
Content copied to clipboard
Manages a default lifecycle for MapboxNavigation.
Call MapboxNavigationApp.setup to specify your NavigationOptions.
Register and unregister your MapboxNavigationObserver instances with MapboxNavigationApp.registerObserver and MapboxNavigationApp.unregisterObserver.
Attach and detach LifecycleOwners to create instances of MapboxNavigation.
Examples
Register and unregister individual LifecycleOwners. Below is an example of creating a single activity that uses MapboxNavigation.
class MyActivity : ComponentActivity() {
override fun onCreate() {
MapboxNavigationApp
.setup(navigationOptions)
.attach(this)
}
override fun onResume() {
MapboxNavigationApp
.registerObserver(locationObserver)
}
override fun onPause() {
MapboxNavigationApp
.unregisterObserver(locationObserver)
}
}
Alternatively, you can enable an entire application by attaching all activities. This will make a MapboxNavigation instance available to any activity or fragment.
class MyApplication : Application() {
override fun onCreate() {
MapboxNavigationApp.setup(this)
.attachAllActivities()
.registerObserver(locationObserver)
}
}
Functions
attach
Link copied to clipboard
attachAllActivities
Link copied to clipboard
current
Link copied to clipboard
detach
Link copied to clipboard
disable
Link copied to clipboard
getObserver
Link copied to clipboard
isSetup
Link copied to clipboard
Indicates whether the MapboxNavigationApp has been setup.
registerObserver
Link copied to clipboard
fun registerObserver(mapboxNavigationObserver: MapboxNavigationObserver): MapboxNavigationApp
Content copied to clipboard
Register an observer to receive the MapboxNavigation instance.
setup
Link copied to clipboard
fun setup(navigationOptionsProvider: NavigationOptionsProvider): MapboxNavigationApp
Content copied to clipboard
unregisterObserver
Link copied to clipboard
fun unregisterObserver(mapboxNavigationObserver: MapboxNavigationObserver): MapboxNavigationApp
Content copied to clipboard
Unregister the observer that was registered through registerObserver.
Properties
lifecycleOwner
Link copied to clipboard