WAYNE PIEKARSKI: Hi, there.
It's time to start writing applications for Android Auto.
I'm Wayne Piekarski from Google.
And today, I'm going to show you how easy it
is to extend your existing messaging
application to support Android Auto.
The Android Auto software runs on your phone
and is responsible for drawing the user interface that
appears on the vehicle's display here.
So the phone connects to the vehicle via USB cable.
And if you want to learn more about how this works,
you should check out our "Introduction to Android Auto"
DevByte.
Android Auto provides extensions that
allow you to easily integrate it with your existing messaging
application.
These extensions allow you to use a voice control
interface optimized for use in a car.
You can use voice controls to reply to message notifications
without having to type on your phone.
This is great, because the user's driving a car,
and they need minimal distractions,
and they need to keep their eyes on the road.
And best of all, Android Auto takes
care of all the hard parts of speech recognition for you.
You just need to add a few extra lines of code.
Oh, look.
Here's a message from my colleague Brian.
Let's see what he has to say.
[BING]
ANDROID: Here's the message.
"You're late for the studio."
[BING]
WAYNE PIEKARSKI: Reply to message.
ANDROID: Say your message.
WAYNE PIEKARSKI: I'll be there in five minutes, Brian.
ANDROID: Here's your message.
"I'll be there in five minutes, Brian."
Do you want to send it?
WAYNE PIEKARSKI: Yes.
ANDROID: Sending message.
WAYNE PIEKARSKI: All right.
Well, let's head off to the studio.
Right now, your existing messaging application
will use notification objects to tell the user
when a message has arrived.
So the notification is going to contain the text of the message
and providing an intent to run when the notification is
selected on the user's phone.
So this is what you already have.
Now, what I'm going to show you now
is how to add some simple notification extensions
to your notification objects to get Android Auto functionality.
To enable the ability to reply to messages from the car,
the first thing you need to do is
to create a remoteInput instance.
And this is going to be responsible for receiving
and processing audio input from Android Auto.
A speech recognizer is used on the spoken audio,
and the notification system will then
deliver this as a plain string to an intent that we provide.
If you've ever done any Android Wear extensions before,
you'll notice this is very similar.
Next, we need to provide to Android Auto
the contents of any unread messages,
so that it can read them out to the user
and possibly take a reply back.
To do this, you firstly create a new UnreadConversation object
from the CarExtender class and provide four pieces
of information-- the name of the person
who sent the message, a time stamp, an intent
to indicate when a message is read,
and a reply action using the previous remote input.
Your messaging application will right now
contain an array or a list of existing messages.
And you'll write a full loop that
traverses through every unread message from the sender
and add them to this UnreadConversation object.
Now you need to take your existing notification code
and add the CarExtender and UnreadConversation objects,
and then issue the notification as you would have done before.
And that's basically it from the Java side.
So you can take your existing code,
and by adding a few extra lines, you
get Android Auto functionality as well.
So to finish up, your application
needs to tell Android Auto that it supports notifications
via CarExtender.
So to do this, you will need to set up your AndroidManifest.xml
to reference an XML file with an automotiveApp
tag along with a notification attribute.
Now, to test your application, we
provide a messaging simulator that
looks very similar to the car experience.
So you can run the simulator on your phone
or in the Android emulator to test
that you're using the API correctly.
It captures the notifications and supports the CarExtender
extensions.
And this is great for testing at your desk
while you're doing the development cycle.
As you can see, the fundamentals of your application
remain the same here, but you added some very simple
extensions to your notification objects
to get Android Auto features.
This means it'll be really easy to extend your existing
messaging application and to get it out to your users.
And what's great about this is that the same style
of extensions used in Android Auto are used for Android Wear
as well, which shows you how extendable the Android
notification system is and how easy it is to get started.
So let's get back out to the car and finish up.
You can find out more about Android Auto by visiting
the documentation site and also joining the Google+ community,
where you can share your ideas with everybody else.
I'm Wayne Piekarski, and thanks very much for joining me.
I'll see you next time.
Navigate to the Googleplex.
[BING]