Page 1 of 1

Google Maps Platform Navigation SDK und Android Automotive (AAOS)

Posted: 01 Feb 2025, 09:38
by Anonymous
FollowMylocation in Googlemap erfordert die Implementierung der NavigationAPI.NavigatorListener -Schnittstelle. Wenn diese Schnittstelle zunächst auf einem Android -Mobilgerät ausgeführt wird, wird ein Dialog eröffnet, in dem die Navigationsbedingungen akzeptiert werden. Die Implementierung dieser Schnittstelle zur Verwendung in Android Automotive (AAOS) öffnet jedoch keinen automatischen Dialog zur Akzeptanz der Bedingungen. Daher löst NavigationAPi Begriffe_Not_accepted Fehler aus. Zeigt die Implementierung von NavigationAPI.NavigatorListener < /p>

Code: Select all

@SuppressLint("MissingPermission")
fun initializeNavigationApi() {
NavigationApi.getNavigator(
foregroundLocationService?.application,
object : NavigationApi.NavigatorListener {
override fun onNavigatorReady(navigator: Navigator?) {
// Disables the guidance notifications and shuts down the app and background service
// when the user dismisses/swipes away the app from Android's recent tasks.
navigator?.setTaskRemovedBehavior(Navigator.TaskRemovedBehavior.QUIT_SERVICE)
navigationViewForAuto!!.getMapAsync { googleMap ->
googleMap.apply {
followMyLocation(GoogleMap.CameraPerspective.TILTED)
isTrafficEnabled = true
}
}
}
override fun onError(@NavigationApi.ErrorCode errorCode: Int) {
when (errorCode) {
NavigationApi.ErrorCode.NOT_AUTHORIZED -> {
// Note: If this message is displayed, you may need to check that
// your API_KEY is specified correctly in AndroidManifest.xml
// and is been enabled to access the Navigation API
Log.i("NAVIGATION API",
"Error loading Navigation API: Your API key is " +
"invalid or not authorized to use Navigation."
)
}
NavigationApi.ErrorCode.TERMS_NOT_ACCEPTED -> {
Log.i("NAVIGATION API",
"Error loading Navigation API: User did not " +
"accept the Navigation Terms of Use."
)
}
else -> Log.i("NAVIGATION API", "Error loading Navigation API: $errorCode")
}
}
}
)
}