I need to get an Activity or Application in my android.car.app.Session class extension which is required to pass in the below method of Google Maps NavigationApi:
NavigationApi.getNavigator(
Application or Activity,
NavigationApi.NavigatorListener
)
Application or Activity is required in this Api to show terms and conditions to be approved.
I have tried to get Service or Activities in Car App Library as shown below:
carContext.getSystemService(CarAppService::class.java).application
carContext.getSystemService(CarAppPermissionActivity::class.java)
But all this attempts resulting with an “Attempt to invoke virtual method ‘android.app.Application androidx.car.app.CarAppService.getApplication()’ on a null object reference” or “The activity provided is null” errors. It is the same (null) with my own extension of CarAppService class.
I have also tried to extend CarAppPermissionActivity but it is restricted.
Is there any way to get an Application or Activity in Androidx Car App Library?