Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or...
Transcript of Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or...
![Page 1: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/1.jpg)
Android Auto App Development Getting Started
Shalini Saxena Honda Silicon Valley Lab
February 4th, 2015
![Page 2: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/2.jpg)
Getting Started with Android Auto Android 5.0 or higher
![Page 3: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/3.jpg)
Important links
Getting Started with Android Auto http://developer.android.com/training/auto/start/index.html
http://developer.android.com/training/auto/audio/index.html
http://developer.android.com/training/auto/messaging/index.html
Android Studio http://developer.android.com/sdk/index.html
Honda Developer Studio
https://developer.hondasvl.com
3
![Page 4: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/4.jpg)
Auto applications
Android Auto supports two types of apps:
– Audio apps that allow users to browse and play music and spoken audio content in the car
– Messaging apps that receive incoming notifications, read messages aloud via text –to-speech and send replies via voice input in the car
4
![Page 5: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/5.jpg)
Setup an Auto Project
Prerequisites
Recommended IDE – Android Studio
Create or update the app project to target Android 5.0
(API Level 21) Set Android manifest targetSdkVersion to 21 or higher
Install the support libraries
5
![Page 6: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/6.jpg)
Setup an Auto Project – contd.
Declare Auto support
Auto XML configuration file, ex. res/xml/automotive_app_desc.xml
Add a manifest entry
6
audio app <automotiveApp>
<uses name="media" />
</automotiveApp>
messaging app <automotiveApp>
<uses name="notification" />
</automotiveApp>
<application> <meta-data android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc"/>
</application>
![Page 7: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/7.jpg)
Audio Apps for Android Auto
7
![Page 8: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/8.jpg)
1-2-3 of building Audio Apps for Auto
1. Configure App Manifest
Auto audio support
Declare a media browser service
2. Build a Browser Service
3. Enable Playback Control
8
![Page 9: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/9.jpg)
1. Configure App Manifest
9
Declare Auto audio support – Auto XML configuration file : res/xml/automotive_app_desc.xml
Declare the media browser service
<application>
... <service android:name=".MyMediaBrowserService" android:exported="true"> <intent-filter> <action android:name= "android.media.browse.MediaBrowserService"/> </intent-filter> </service> ... <application>
![Page 10: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/10.jpg)
2. Building a media browser service
Build a service that provides audio track listing information - extend MediaBrowserService.
Register a MediaSession object
Get the token for your app's MediaSession object, in order to control audio playback
Implement the MediaSession.Callback object to enable playback controls.
10
![Page 11: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/11.jpg)
Media browser service
Important functions in the service implementation onCreate()
Declare MediaSession object and its callback object
Build content hierarchy with: onGetRoot()
returns information about the root node of the menu hierarchy
onLoadChildren()
Auto device client builds the top-level menu by calling this method with the root node object and getting it's children
Builds submenus by calling it with other child nodes
11
![Page 12: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/12.jpg)
3. Enable playback controls
Register MediaSession object
Implement play commands using the MediaSession.Callback object
• onPlay()
• onPause()
• onPlayFromMediaId()
• onPlayFromSearch()
• onPause()
• onSkipToNext()
• onSkipToPrevious()
• onStop()
12
![Page 13: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/13.jpg)
Messaging apps for Auto
13
Message notification
![Page 14: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/14.jpg)
Messaging App – Read Message to User
14
![Page 15: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/15.jpg)
1-2-3-4 of building messaging apps for Auto
1. Configure App Manifest
Auto messaging support
Define read and reply intent filters
2. Import Support Library for Messaging
3. Notify User of Messages
4. Handle User Actions
15
![Page 16: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/16.jpg)
1. Configure App manifest file
Declare Auto notification support – Auto XML configuration file : res/xml/automotive_app_desc.xml
Define the read and reply intent filters
16
<application>
...
<receiver android:name=".MyMessageReadReceiver">
<intent-filter>
<action android:name="com.myapp.messagingservice.ACTION_MESSAGE_HEARD"/>
</intent-filter>
</receiver>
<receiver android:name=".MyMessageReplyReceiver">
<intent-filter>
<action android:name="com.myapp.messagingservice.ACTION_MESSAGE_REPLY"/>
</intent-filter>
</receiver>
...
<application>
![Page 17: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/17.jpg)
2. Import Support Library for Messaging
Update the v4 Support Library Extras > Android Support Repository to version 9 or higher
Extras > Android Support Library to version 21.0.2 or higher.
Import the library into the Android Studio development project by adding this dependency to your build.gradle file:
17
dependencies {
...
compile 'com.android.support:support-v4:21.0.+'
}
![Page 18: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/18.jpg)
3. Notify Auto User of Messages
Build and send a specific type of notification for display on Auto devices
Build message conversations
Associate Read and Reply Intents with each conversation
Send message as notification to Auto device
18
![Page 19: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/19.jpg)
Build message conversations
NotificationCompat.CarExtender.UnreadConversation class
PendingIntent
Add messages to the UnreadConversation object
19
//Build a RemoteInput for receiving voice input in a Car Notification
RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
.setLabel(getApplicationContext()
.getString(R.string.notification_reply))
.build();
//Create an unread conversation object to organize a group of messages
//from a particular sender.
UnreadConversation.Builder unreadConvBuilder =
new UnreadConversation.Builder(participantName)
.setReadPendingIntent(msgHeardPendingIntent)
.setReplyAction(replyPendingIntent, remoteInput);
// Note: Add messages from oldest to newest to the UnreadConversation.Builder
for (Iterator<String> messages = conversation.getMessages().iterator();
messages.hasNext(); ) {
String message = messages.next();
unreadConvBuilder.addMessage(message);
![Page 20: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/20.jpg)
Read and Reply Intents
PendingIntent for read and reply actions are associated with each unread conversation
20
Intent msgHeardIntent = new Intent()
.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
.setAction(com.myapp.messagingservice.ACTION_MESSAGE_HEARD)
.putExtra("conversation_id", conversationId);
PendingIntent msgHeardPendingIntent =
PendingIntent.getBroadcast(
getApplicationContext(),
conversationId,
msgHeardIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
![Page 21: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/21.jpg)
Send Messages as notification to Auto
Add message to the NotificationCompat.CarExtender.UnreadConversation.Builder for this conversation, and update its timestamp:
Build notification
21
unreadConvBuilder.addMessage(messageString).setLatestTimestamp(currentTimestamp);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(icon_bitmap)
.setContentText(messageString)
.setWhen(currentTimestamp)
.setContentTitle(participant_name)
.setContentIntent(msgHeardPendingIntent);
![Page 22: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/22.jpg)
Send Messages as notification to Auto
Create and attach
NotificationCompat.CarExtender.UnreadConversation object to
NotificationCompat.CarExtender
Send notification using app’s NotificationManagerCompat
22
notificationBuilder.extend(new CarExtender()
.setUnreadConversation(unreadConvBuilder.build());
NotificationManagerCompat msgNotificationManager =
NotificationManagerCompat.from(context);
msgNotificationManager.notify(notificationId, notificationBuilder.build());
![Page 23: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/23.jpg)
4.Handle Auto User Action - BroadcastReceiver
Configure your app to receive Intent objects that indicate
Auto user has read or replied to a message.
Read/Heard Action
Reply Action
When the user hears or replies to a message the Auto device sends a read/reply intent
App invokes the broadcast receiver class associated to it to handle that action
23
![Page 24: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/24.jpg)
Testing the apps
• Using the Simulator
From the Extras install the Android Media Browser simulator on
the test device • Audio <sdk>/extras/google/simulators/media-browser-simulator.apk
• Messaging <sdk>/extras/google/simulators/messaging-simulator.apk
• Honda Developer Studio
Register to become a part of the HDS
24
![Page 25: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/25.jpg)
Important links
Getting Started with Android Auto http://developer.android.com/training/auto/start/index.html
http://developer.android.com/training/auto/audio/index.html
http://developer.android.com/training/auto/messaging/index.html
Android Studio
http://developer.android.com/sdk/index.html
Honda Developer Studio
https://developer.hondasvl.com
25
![Page 26: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/26.jpg)
Introduction to
John Moon Honda Silicon Valley Lab
February 4th, 2015
![Page 27: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/27.jpg)
Honda Silicon Valley Lab & HDS
![Page 28: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/28.jpg)
HSVL Mission: Open Innovation
Connected Vehicle Human Machine Interface
Apps/Contents Big Data
28
![Page 29: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/29.jpg)
What is Honda Developer Studio?
• Open-innovation, collaborative workspace in Mountain View, CA
• Online portal – http://developer.hondasvl.com/
![Page 30: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/30.jpg)
Benefits to Developers
• Latest platform information
• Access to test vehicles
• Access to Honda engineering team
• Be involved in the automotive community
![Page 31: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/31.jpg)
Studio Visit
1. Register online and make an appointment
2. Meeting with engineering team to discuss your application
3. HDS loads your application for the test drive
4. HDS provide feedback and answer any questions
![Page 32: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/32.jpg)
Input and Output
32
Telephony Buttons
Audio Controls
Microphone
Audio System
USB (to Phone)
Display
User Inputs Outputs
![Page 33: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/33.jpg)
Load Your App on Our Environment
Developer’s APK
![Page 34: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/34.jpg)
Take a Test Drive
![Page 35: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/35.jpg)
http://developer.hondasvl.com
![Page 36: Android Auto App Development Getting Started...Extras > Android Support Repository to version 9 or higher Extras > Android Support Library to version 21.0.2 or higher. Import the library](https://reader030.fdocuments.in/reader030/viewer/2022041120/5f32ed856b615444dc685086/html5/thumbnails/36.jpg)
Thank You for your attention