What is Android Auto?
Android Auto provides a driver-optimized app experience for users who have an Android phone and the Android Auto app. It’s an extension of a connected Android smartphone to a compatible car that can display some apps, entertainment, and mirror messages on a car’s dashboard. We can connect our device using USB or Bluetooth.
Android Auto is only compatible with phones running Android 6.0 (API level 23) or higher
When you’ll connect your phone to the car, all your Android Auto-compatible apps will be accessible.
What is Android Automotive OS?
Android Automotive OS is an Android-based infotainment system that is built into vehicles. The car’s system is a standalone Android device that is optimized for driving. With Android Automotive OS, users install your app directly onto the car instead of their phones.
Android Auto and/or Android Automotive OS support the following types of apps:
- Media apps — audio: Media apps let users browse and play music, radio, audiobooks, and other audio content in the car.
- Messaging apps: Messaging apps let users receive incoming notifications, read messages aloud using text-to-speech, and send replies via voice input in the car.
- Navigation apps: Navigation apps, including providers of driver and delivery services, help users get where they want to go by providing turn-by-turn directions
- Point of Interest (POI) apps: POI apps let the user discover and navigate to points of interest and take relevant actions, such as parking, charging, and fuel apps
- Internet of Things (IOT) apps: IOT apps let users take relevant actions on connected devices from within the car.
- Video apps (for use while parked): Video apps let users view streaming videos while the car is parked.
- Games (for use while parked): Game apps let users play games while the car is parked.
Your App must be of one of those categories above only. you will declare it in the Manifest and this will be reviewed by Google
Configuration to start exploring Android Auto device and setting up emulator
The Desktop Head Unit (DHU) enables your development machine to emulate an Android Auto head unit, so that you can run and test Android Auto apps.
The DHU runs on Windows, Mac os, and Linux systems.
Follow the below steps to enable Android Auto Emulator
- Enable Developer mode on a mobile device running Android 6.0 (API level 23) or higher.
- Compile and install your app on the device.
- Install Android Auto on the device. If Android Auto is already installed, make sure that you are using the latest version.
- Open SDK Manager and navigate to SDK Tools tab, then download Android Auto Desktop Head Unit Emulator package.
5. DHU is installed in the
6. Linux or Mac os systems, run the following command in that directory to ensure the DHU binary is executable:
chmod +x ./desktop-head-unit
7. Emulator will start working and check your Android device if any popup showing related to update, click on update option and restart Emulator.
Android Auto Design Templates
In Android Auto, We can’t create our custom UI and we can use some set of templates which is only allowed for Android Auto apps.
According to me, the predefined UI Templates provided by Google will give better usability to the driver in order to coordinate with the Android auto device while driving.
List of available Templates:
- Tab Container Template
— Tab bar with app icon and up to 4 tabs (no back button)
— Embedded template, which can be any of the following types: List , Grid, Search, Pane, or Message
- List or Grid Template
- Message or Long Message Template
- Search Template
- Place List (map) Template
- Navigation Template
Steps to build media apps for cars
- Declare Android Auto Support in Manifest file
- Declare your media browser service
How Android Auto interact with your media browser service:
- User launches your app on Android Auto and Android Auto contacts your app’s media browser service using the
onCreate() method. In your implementation of the
onCreate()method, you must create and register a
MediaSessionCompat object and its callback object.
- Android Auto calls your service’s
onGetRoot() method to get the root media item in your content hierarchy. Everything starts at the root and you must return a non-null BrowserRoot to allow connections to your MediaBrowserServiceCompat.
- Android Auto calls your service’s
onLoadChildren() method to get the children of the root media item. Android Auto display these media items as the top level of content items. We have two available flags FLAG_PLAYABLE and FLAG_BROWSABLE which indicates media item can be directly played or It has children of its own
- If the user selects a browsable media item, your service’s
onLoadChildren()method is called again to retrieve the children of the selected menu item.
- If the user selects a playable media item, Android Auto calls the appropriate media session callback method to perform that action.
Example: It will start playing music item.
Mandatory steps to support Android Auto in Media Apps :
Set standard playback actions
Android Auto display playback controls based on the actions that are enabled in the
By default, your app must support the following actions:
Your app can additionally support the following actions if they are relevant to the app’s content:
Media Controller Test is useful if you want to test your media app controls.
Media Controller Test (MCT) app allows you to test the intricacies of media playback on Android and helps verify your media session implementation.
The MCT includes tests for the following media actions:
- Play From Search
- Play From Media ID
- Play From URI
- Skip To Next
- Skip To Previous
- Skip To Queue Item
- Seek To
Support voice actions
Your media app must support voice actions to help provide drivers with a safe and convenient experience that minimizes distractions. When Android Auto detects and interprets a voice action, that voice action is delivered to the app through
onPlayFromSearch(). On receiving this callback, the app finds content matching the
query string and starts playback.
Custom playback actions
You can add custom playback actions to display additional actions that your media app supports. Each custom action that you create requires an icon resource. Apps in cars can run on many different screen sizes and densities, so icons that you provide must be vector drawables.
Example: Shuffle 🔀, Repeat 🔁, Repeat Single song 🔂, etc
I personally feel if your app is media app, messaging app, navigation parking app, etc then we should support Android Auto platform too, which will help driver while using the app. Voice command support is useful when user want to avoid looking at screen while driving.
Well, that’s all for now. In future articles, I will share sample app with Android Auto and Android Automotive implementation.
UAMP Media App is a very useful repository which you can explore for Android Auto and Android Automotive OS both
Thank you for taking the time to read this article. If you found this post to be useful and interesting, please clap 👏 and recommend it.
You can reach me on social media and other platforms, stay tuned: https://linktr.ee/droiddikshit 🤝
https://github.com/android/uamp (Android Media app UAMP)
This article was previously published on proandroiddev.com