> [!WARNING]
> **Warning:** For apps that use the `CarConnection` API and [target](https://developer.android.com/guide/topics/manifest/uses-sdk-element.md.txt#target) Android 14 (API level 34) and higher, use Car App Library version `1.3.0-beta01` or later. Earlier versions of the library throw an exception on devices running Android 14 or later due to the requirement for [context-registered receivers to specify export behavior](https://developer.android.com/about/versions/14/behavior-changes-14.md.txt#runtime-receivers-exported).  
>
> Regardless of the Car App Library version, for apps that target Android 13 (API level 33) or lower, `CarConnection` API doesn't encounter this issue, even on a device running Android 14 or higher.

To determine if your app is running on Android Auto or Android Automotive OS,
use the [`CarConnection` API](https://developer.android.com/reference/androidx/car/app/connection/CarConnection.md.txt) to retrieve connection information at runtime.
For example:

1. In your car app's `Session`, initialize a `CarConnection` and subscribe to `LiveData` updates:


```kotlin
CarConnection(carContext).type.observe(this, ::onConnectionStateUpdated)
```

<br />

1. In the observer, react to changes in the connection state:


```kotlin
fun onConnectionStateUpdated(connectionState: Int) {
    val message = when (connectionState) {
        CarConnection.CONNECTION_TYPE_NOT_CONNECTED -> "Not connected to a head unit"
        CarConnection.CONNECTION_TYPE_NATIVE -> "Connected to Android Automotive OS"
        CarConnection.CONNECTION_TYPE_PROJECTION -> "Connected to Android Auto"
        else -> "Unknown car connection type"
    }
    CarToast.makeText(carContext, message, CarToast.LENGTH_SHORT).show()
}
```

<br />