Build your mobile app with Google Cloud Platform
Articles,  Blog

Build your mobile app with Google Cloud Platform

[MUSIC PLAYING] Hi, I’m Laura, from Google. Did you know that you can use
the Google Cloud Platform to build your own mobile backend on
Google’s infrastructure in five minutes? Let me show you how. In this tutorial, we’ll be
building an app that allows a user to shop smart by getting
information on products she’s looking for at the store
she’s in, as well as find stores nearby. We’ll be using some custom code
to wire a basic Android app front end with an App Engine
Cloud backend using Google Cloud Endpoints, so the
phone can determine customer location, and the app can locate
nearby stores and allow the customer to get relevant
offers and recommendations. Let’s get started. I’ve already installed and
configured my IDE with all the right tools and SDKs. First, we’re going to create
the project for the Android client application, and start
building the app. We’ll create an entity class to
define the data structure, generate Cloud Endpoint classes
to give us the backend infrastructure and APIs, and
then generate a related client library to make calling
the server APIs from our mobile app easy. In our Eclipse project, let’s
create a new class and name it check in. These classes allow for
communication between the client and the backend. Click to generate the Cloud
Endpoint class. You can see now that the check
in file is generated in our Apps backend. To generate the related client
library, let’s open the package explorer and
our project. In a few clicks, we generate
the check in endpoint client library. Now that we’ve created the
communication mechanism, we need to add more logic to the
mobile client app to talk to the entity and Cloud
Endpoint classes. Once we do this, the
app will be able to call back to the server. For our app, this means we’ll
be able to retrieve store information contained in
the backend data store. Let’s create a new entity
class in our app. This will represent places– such as stores– near the customer’s current
location in real time. Let’s create that new class
and name it Place. We’ll navigate to the package
explorer and generate a Cloud Endpoint class. Then, we’ll also generate
another Cloud Endpoint client library. Now that we’ve told the app
how to understand store addresses, let’s modify the
client to actually obtain information from the backend
and display it in our app. What I’m doing is expanding the section, where our front end code is
located, and adding in more code, which includes the global
results list variable. This contains the information
about the store locations obtained from the backend. And now we’ve got the app
infrastructure in place between the client and the
mobile backend using Google Cloud Endpoints. We just did a lot. We created a bunch of objects
and classes, built the infrastructure, wired up the
Android app to call back to the server, and got the app to
display a list of stores. Next, let’s add logic that
allows the customer to perform the actual tasks of checking
in to a place and obtaining information about the
sales and offers. First, we need to create the
client-user interface so users can access the information,
then we can add offers and recommendations logic to the
backend and to the client. Let’s modify a few files to
improve the interface. We replace TextView with
ListView, which contains the code to list nearby places. We add the
placesListClickListener event handler, which helps the client
understand user clicks, and lets it know when to
activate the logic that performs the check in tasks. Finally, in the onPostExecute
method, we create a list adapter to better display the
information with icons. Let’s now add a few things to
the file to improve the interface
even more. We add activity_main.xml, which
defines the UI layout for buttons and places. We add place_item.xml, which
contains information about display format and position. And finally, we add strings.xml,
which contains pre-defined strings to display
when the user might get relevant offers or
recommendations. Now that we’ve created the
client-user interface, we need to add classes that allow the
app to obtain information about offers available and
shopping recommendations for each store. We can add the
entity class and the
entity class– one for gathering offers, and
one for gathering shopping recommendations. In the same way we added the class, we’re going to create our related class and
class. Again, this creates the related
client libraries automatically. Finally, we’re going to add
the logic to the client so that the customer can actually
see offers and shopping recommendations displayed. We modify
to add the placesListClickListener event
handler, so that when a customer clicks on an item in
the list of nearby places, it’ll provide offers and
recommendations. We’re done with all
the coding. Let’s deploy an instance
to see our app live. Check it out. In five minutes, we were able to
control our Android app by writing custom code to wire
the app to Google Cloud Endpoints, enhancing the
user experience, and saving us time. Now, you should go download the
code and the tutorial, and give it a shot doing
it on your own. [MUSIC PLAYING]


Leave a Reply

Your email address will not be published. Required fields are marked *