Navigation state
Navigation SDK UX Framework uses a sophisticated state machine to manage its navigation states effectively. This state machine enables the UX Framework to transition between different operational modes smoothly, providing users with an intuitive and dynamic navigation experience.
There are four Navigation States that UX Framework can be in:
FreeDrive
. This is the default starting state for the UX Framework.TripPlanning
. UX Framework will enter the Trip Planning state upon presenting search results or setting a destination.
ActiveGuidance
. Once the destination is set and the start navigation button has been pressed, UX Framework will enter the Active Guidance state.Arrival
. UX Framework will enter the Arrival state upon approaching a stop or the end of the route.
The host application can observe the Navigation State changes through the Dash.controller
instance.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED) {
Dash.controller.observeNavigationState()
.collect { /* NavigationState */ state ->
// Do something with the NavigationState
processNavigationState(state)
}
}
}
}
fun processNavigationState(state: NavigationState) {
when (state) {
is NavigationState.FreeDrive ->
Toast.makeText(
this,
"Drive safe",
Toast.LENGTH_SHORT
).show()
is NavigationState.TripPlanning ->
Toast.makeText(
this,
"Let's plan our trip",
Toast.LENGTH_SHORT
).show()
is NavigationState.ActiveGuidance ->
Toast.makeText(
this,
"3.. 2.. 1.. GO!",
Toast.LENGTH_SHORT
).show()
is NavigationState.Arrival ->
Toast.makeText(
this,
"Almost there!",
Toast.LENGTH_SHORT
).show()
}
}
}
この{Type}は役に立ちましたか?