Google maps platform navigation SDK and Android Automotive (AAOS) - Stack Overflow

admin2025-04-17  4

followMyLocation in GoogleMap requires implementation of NavigationApi.NavigatorListener interface. When at first run on an Android mobile device this interface opens automoatically a dialog asking to accept Navigation terms and conditions. But implementation of this interface for use in Android Automotive (AAOS) does not open automatically a dialog to accept the terms and conditions. Therefore NavigationApi throws TERMS_NOT_ACCEPTED error.

Is there any way to show terms and conditions for Google Navigation applications running in Android Automotive devices?

Below code snipped shows the implementation of NavigationApi.NavigatorListener

@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")
                }
            }
        }
    )
}

followMyLocation in GoogleMap requires implementation of NavigationApi.NavigatorListener interface. When at first run on an Android mobile device this interface opens automoatically a dialog asking to accept Navigation terms and conditions. But implementation of this interface for use in Android Automotive (AAOS) does not open automatically a dialog to accept the terms and conditions. Therefore NavigationApi throws TERMS_NOT_ACCEPTED error.

Is there any way to show terms and conditions for Google Navigation applications running in Android Automotive devices?

Below code snipped shows the implementation of NavigationApi.NavigatorListener

@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")
                }
            }
        }
    )
}
Share Improve this question asked Feb 1 at 8:38 EmrahEmrah 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The Google Maps/Navigation SDK isn't currently supported on Android Automotive OS Cars with Google built-in, so that may be part of the issue.

转载请注明原文地址:http://anycun.com/QandA/1744834362a88268.html