# Android Automotive

Android Automotive is a base Android platform that runs pre-installed IVI system Android applications as well as optional third-party Android Applications.

***

* **Android Auto** is a platform running on the user’s phone, projecting the Android Auto user experience to a compatible in-vehicle infotainment system over a USB connection.
* **Android Automotive** is an operating system and platform running directly on the in-vehicle hardware. It is a full-stack, open source, highly customizable platform powering the infotainment experience

***

### Advantages

* Integrating into existing environment
* Security
* Power consumption
* Development community
* Scalability
* Connectivity
* Updates and upgrades
* Open source
* OTA( Over the air) updates
* real-time feedback on battery levels, range, and the closest charging stations
* Integration with IOT

### Disadvantage

* Dependency on google services
* Resource intensiveness
* Security concerns
* Dependency on internet
* Initial implementation cost

### Limitations for development

1. **Limited Hardware Access:** Developers may have restricted access to certain hardware features in the vehicle due to security and safety concerns. This limitation is in place to prevent actions that could interfere with the vehicle's operation.
2. **Specialized User Interface Guidelines:** Android Automotive has specific guidelines for designing user interfaces tailored for in-vehicle use. Developers need to adhere to these guidelines, which might limit creativity but are essential for maintaining a consistent and safe user experience.
3. **Regulatory Compliance:** Development for Android Automotive in the automotive industry is subject to various regulations, especially concerning driver distraction. Developers need to ensure that their applications comply with these regulations, which can impact the design and functionality of the apps.
4. **Testing Challenges:** Testing applications for Android Automotive requires specialized testing environments that simulate in-vehicle conditions. This could be challenging for developers who may not have easy access to the required testing setups.
5. **Fragmentation Across Manufacturers:** Different car manufacturers may customize the Android Automotive platform, leading to fragmentation. Developers need to account for these variations, ensuring that their apps work seamlessly across different implementations.
6. **Limited APIs for Vehicle Data Access:** Access to certain vehicle data may be restricted, limiting the scope of applications that can interact with specific vehicle functions. This is done to maintain safety and security standards.
7. **Dependency on Connectivity:** Some applications may heavily rely on internet connectivity, and in areas with poor or no network coverage, users may experience limitations in functionality. Developers need to consider offline capabilities when designing apps.
8. **Security Concerns:** Security is a critical aspect, given that Android Automotive applications are part of the in-vehicle system. Developers need to follow secure coding practices and consider potential vulnerabilities that could compromise the safety of the vehicle and user data.
9. **Learning Curve for New APIs:** Developers need to familiarize themselves with new APIs and features specific to Android Automotive. This learning curve can impact development timelines, especially for those transitioning from traditional Android app development.
10. **Limited Documentation:** Depending on the specific version and implementation of Android Automotive, developers may find varying levels of documentation and resources. This can pose challenges in understanding and utilizing certain features.

***

```xml
// AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-feature
        android:name="android.hardware.type.automotive"
        android:required="true" />

    <uses-feature
        android:name="android.software.car.templates_host"
        android:required="true" />

    <uses-feature
        android:name="android.hardware.wifi"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.screen.portrait"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.screen.landscape"
        android:required="false" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />

    <application
        android:allowBackup="true"
        android:appCategory="audio"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.WeatherApp" >
        <service
            android:name=".MyCarAppService"
            android:exported="true">
            <intent-filter>
                <action android:name="androidx.car.app.CarAppService"/>
                <category android:name="androidx.car.app.category.POI"/>
            </intent-filter>
        </service>
        <activity
            android:exported="true"
            android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
            android:name="androidx.car.app.activity.CarAppActivity"
            android:launchMode="singleTask"
            android:label="Android Automotive">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <meta-data android:name="com.akshay.weatherapp"
            android:resource="@xml/automotive_app_desc"/>
        <meta-data
            android:name="androidx.car.app.minCarApiLevel"
            android:value="1"/>
        <meta-data
            android:name="distractionOptimized"
            android:value="true" />
    </application>

</manifest>
```

```xml
// automotive_app_desc
<?xml version="1.0" encoding="utf-8"?>
<automotiveApp >
<uses name="template"/>
</automotiveApp>
```

```kotlin
// Service
class MyCarAppService : CarAppService(){
    override fun createHostValidator(): HostValidator {
        return HostValidator.ALLOW_ALL_HOSTS_VALIDATOR
    }

    override fun onCreateSession(): Session {
        return WeatherAppSession()
    }
}

//Session
class WeatherAppSession : Session() {
    override fun onCreateScreen(intent: Intent): Screen {
        return MainScreen(carContext)
    }

}
```

<figure><img src="/files/z48lGjoRFJ0ukmfo9ZWJ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/bTE4nSSSVnu0nRvuxoxz" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/INOG5qlaITFOz2oD9cBa" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/android/car-samples/issues/6>" %}

{% embed url="<https://medium.com/tribalscale/android-automotive-development-challenges-a4eee14a1aaf>" %}

{% embed url="<https://developer.android.com/training/cars/apps#create-carappservice>" %}

{% embed url="<https://grapeup.com/blog/developing-apps-for-android-automotive-os/>" %}

{% embed url="<https://blog.stackademic.com/how-does-android-automotive-work-with-the-latest-car-technologies-9021e79102b8>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://akshay-2.gitbook.io/android_automotive/android-automotive.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
