Tip:
Highlight text to annotate it
X
LAURENCE MORONEY: Wearable computing
is a massive growth area with an expected market
share worth over $8 billion in the next four years.
Now, that's a lot of people with a new way
of interacting with your apps.
But how do you get started?
What does it take to build an app
that you can use on your wrist?
Hi, I'm Laurence from the Google Developers Relations team.
And in this video, we're going to take a look
at exactly how you can do that-- run apps on your watch.
Now, building an app like this has
three main architectural components.
First, there's the cloud service that
provides your app's backend.
So for example, if you're building a service to watch
stocks and you want it to notify you when one has changed
by a certain amount-- say up or down by 1%--
this is the type of thing that you can build your backend
service to do.
Now second, there's a mobile app that
interfaces with this service.
The app can generate notifications
that you can see on your device.
And it can also be sent to any attached Android Wear device.
And third, of course, is the Android Wear app itself.
The Android Wear features are actually
built into the mobile app, so that when
it generates notifications that you see on the phone,
they're also rendered to the Android Wear device.
Now, there are also APIs that allow
you to deliver these notifications
so that the Android Wear user can do interesting things
with them, such as triggering response actions.
So, say for example in our stock trading application,
if we get a notification that a stock we're interested in
has dropped by more than 1%, we might
want to buy in because it's a bargain.
Now, how do we do all of this?
Android Studio actually gives you everything
that you need to do this.
It includes tools for building the backend services
as well as, of course, the Android phone app.
And now you can get the extensions
that you need for handling Android Wear.
The cloud backend can be built with an exposed API.
Android Studio's tools allow you to do this in Java,
and it handles the fine details of the plumbing for you.
You can write cloud backends that
expose an API for your Android app using attribution.
Now you can see some examples of this in the code here.
These attributes tell the Android client
what this code does, such as implementing an API called
quotesApi, and providing a method called getQuote.
OK, now once you've built your cloud service,
and with the tools you can actually automatically create
client libraries to access that.
Now next, of course, you have to build your app.
How do you access your API from your app?
Well, the classes were downloaded for you
into your Maven repository.
So you can simply include them using
your built up gradle file, like you can see here.
Now, remember earlier when we attributed our API
and we called it quotes API?
That's exactly what you see here.
Now, from your Android app, you can simply
use these classes to talk to the API backend.
Earlier, when we created the API,
we used the attribute API method on a function
and we called it getQuote.
Now you can see there's a getQuote function in the client
classes.
And guess what they do?
Yup, they get a quote for me.
This is the typical cloud powered Android app.
But now how do we extend that for Android Wear?
Notifications on my phone will display on my phone,
but let's update the code to generate notifications
so that they display on my device.
And they'll also display when the stock prices, say, change
by more than 1%.
When this code generates a notification,
it'll show up on my Android device as you can see here.
But they'll also show up on my Android Wear device
with an optimized UI for the device's form factor.
Now let's see how we can add feedback
so that the user can tell my app to buy or sell stock
based on the notification by interacting with our Android
Wear device.
You can see that code here.
Now let's see what happens when I
get a notification on my device.
You can see that I now have cards
that allow me to interact, to do things
such as buying or selling.
When I say buy, the command will be sent back to my phone
where I can process it.
Now, this is a stock trading application,
so for something like this, I might access my portfolio
to do an actual trade.
And that's how easy it is to build a Cloud powered Android
app.
You first build your backend complete with an API
using Cloud Endpoints.
You then build your Android application
that consumes this API.
And then finally, you extend that application
to handle the interface with an attached Android Wear device.
If you want to see a full walkthrough of how
to build the stock trader application I've been talking
about in this video, visit the link shown here.
And I can't wait to see what you're
going to build for the wearable cloud.
Thank you very much.