Programming Google Glass 2nd Edition Build Great Glassware Apps With The Mirror API and GDK Eric Redmond Download PDF
Programming Google Glass 2nd Edition Build Great Glassware Apps With The Mirror API and GDK Eric Redmond Download PDF
https://ebookfinal.com/download/google-glass-for-dummies-1st-edition-
eric-butow/
ebookfinal.com
https://ebookfinal.com/download/mining-google-web-services-building-
applications-with-the-google-api-1st-edition-john-paul-mueller/
ebookfinal.com
Glass Mechanics and Technology 2nd Edition Eric Le Bourhis
https://ebookfinal.com/download/glass-mechanics-and-technology-2nd-
edition-eric-le-bourhis/
ebookfinal.com
https://ebookfinal.com/download/hire-with-your-head-using-power-
hiring-to-build-great-teams-2nd-edition-lou-adler-2/
ebookfinal.com
https://ebookfinal.com/download/hire-with-your-head-using-power-
hiring-to-build-great-teams-2nd-edition-lou-adler/
ebookfinal.com
https://ebookfinal.com/download/tapworthy-designing-great-iphone-
apps-1st-edition-josh-clark/
ebookfinal.com
Programming Google Glass 2nd edition Build Great
Glassware Apps with the Mirror API and GDK Eric
Redmond Digital Instant Download
Author(s): Eric Redmond
ISBN(s): 9781941222188, 1941222188
Edition: 2
File Details: PDF, 9.81 MB
Year: 2015
Language: english
www.it-ebooks.info
Under Construction: The book you’re reading is still under
ß
development. As part of our Beta book program, we’re releasing
this copy well before a normal book would be released. That
way you’re able to get this content a couple of months before
it’s available in finished form, and we’ll get feedback to make
the book even better. The idea is that everyone wins!
Be warned: The book has not had a full technical edit, so it will contain errors.
It has not been copyedited, so it will be full of typos, spelling mistakes, and the
occasional creative piece of grammar. And there’s been no effort spent doing
layout, so you’ll find bad page breaks, over-long code lines, incorrect hyphen-
ation, and all the other ugly things that you wouldn’t expect to see in a finished
book. It also doesn't have an index. We can’t be held liable if you use this book
to try to create a spiffy application and you somehow end up with a strangely
shaped farm implement instead. Despite all this, we think you’ll enjoy it!
Send us your feedback: In the meantime, we’d appreciate you sending us your
feedback on this book at pragprog.com/titles/erpgg2/errata, or by using the links
at the bottom of each page.
www.it-ebooks.info
Programming Google Glass,
Second Edition
Build Great Glassware Apps with the Mirror API and GDK
Eric Redmond
www.it-ebooks.info
Many of the designations used by manufacturers and sellers to distinguish their products
are claimed as trademarks. Where those designations appear in this book, and The Pragmatic
Programmers, LLC was aware of a trademark claim, the designations have been printed in
initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer,
Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking g device are trade-
marks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes
no responsibility for errors or omissions, or for damages that may result from the use of
information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team create
better software and have more fun. For more information, as well as the latest Pragmatic
titles, please visit us at https://pragprog.com.
www.it-ebooks.info
Contents
Preface . . . . . . . . . . . . . . ix
www.it-ebooks.info
Contents • iv
Cron Jobs 56
Wrap-Up 58
www.it-ebooks.info
Contents •v
www.it-ebooks.info
Contents • vi
Index . . . . . . . . . . . . . . 295
www.it-ebooks.info
Changes in the Beta Releases
P1.0, Feb 13, 2015
• Replaced all ADT examples in Part Two with Android Studio.
Beta 3, Dec 15
• Added the final chapter, Chapter 16, Turning an Android App to Glassware,
on page 265.
Beta 2, November 13
• Added Chapter 15, Preparing For the Real World, on page 245.
Beta 1, October 21
You can program Glassware (Glass applications) in two ways: by using the
HTTP-based Mirror API web-service, or by creating native applications using
the Glass Development Kit (GDK). This book covers how to program both.
You’ll get a glimpse of what Glass is and what it is not, and how users can
interface with Glass. In Part One of this book you’ll learn how to develop a
Glass application fast, by using the Mirror API to manipulate timeline cards
and menus, track a Glass’s geolocation, create rich interactions by responding
to user inputs, and capture or serve user images and videos. In Part Two
you’ll learn how to shape user experience with the GDK by interacting with
Glass hardware, from voice-to-text inputs, to QR code reading with the live
camera, to building your own video game with fine-grained sensor inputs.
You’ll see how to properly design new Glassware or update existing applica-
tions to become Glassware. This is the book to read if you want a shortcut to
this brave new world.
to watch your favorite movies, a panel would hover conveniently in the air
visible only to you, or sharable with friends who wish to watch as well. The
idea of Google Glass is not to add more technology to your daily life, but rather
sit idly in the background, available when you need it. It’s about getting
technology out of your way, while still providing its benefits.
The first future-facing movie that I can recall containing consumer HUD
(heads-up display) goggles was Back to the Future 2. This HUD was worn in
the future year 2015 (I know, right?), not by a military commander or an air-
ship pilot, but by young Marty McFly, Jr., as he sat with his family around
the kitchen table. This was a consumer device capable of, at least, displaying
text and accepting phone calls.
The pertinent code is covered in the book, and the rest can be downloaded
along with the book (or from GitHub.1)
You needn’t be a Java expert to follow Part One of this book, but it can help
to know your way around the syntax and Eclipse editor. You may also get
more out of Part One if you’re familiar with Google App Engine, although you
can use any Platform as a Service (PaaS) or host your own Glassware applica-
tions. Part Two requires a much more in depth knowledge of Java, and there
we’ll be using The Intellij-based Android Studio.
1. https://github.com/coderoshi/glass
Part One
After an introduction to Glass and two styles of programming Glassware in
Chapter 1, Wrapping Your Head Around Glass, on page 1, we will dive into
the Mirror API web service. In Part One we work on slowly building up a
complete Glassware, along the way using most of the components of the
Mirror API. Although I’d recommend you read both the Mirror API and GDK
parts to get a full appreciation of your Glassware options, you are free to skip
straight to Part Two if you have no interest in the Mirror API service.
2. https://developers.google.com/glass/develop/
Part Two
The chapters in Part Two are designed to build up from simple to more complex
examples. Unlike Part One, however, the examples in each chapter are self
contained. You should follow these chapters in order, rather than jump
around, since previous sections are sometimes refered to later.
rendered by the Mirror API. We’ll create and launch a live card application to
gradually display statistics about the inner workings of Glass, including a
simple menu to close it.
Online Resources
You can download the code and other resources used in this book from the
Pragmatic Bookshelf website or my GitHub repository.3 4 You are free to use
this source code for anything you wish.
You’ll also find the community forum and the errata-submission form on the
Pragmatic site, where you can report problems with the text or make sugges-
tions for future versions.
The official Google Mirror API is also an excellent resource for the most up-
to-date changes in the API, as well as other viewpoints on creating Glassware.5
Getting Going
Wearable computers, like Google Glass, are a growing topic, getting larger by
the day. We could have easily created a book twice this length on Glass con-
cepts, the Mirror API, good design, musings on the future, and so on. It was
a conscious decision to keep this book slim so you can get a quick head start
on this future.
Eric Redmond
Feb 2015
3. pragprog.com/book/erpgg/programming-google-glass
4. https://github.com/coderoshi/glassmirror
5. http://developers.google.com/glass/
And as you can see in the figure, wearing Glass looks cool.
1. http://en.wikipedia.org/wiki/Computer_form_factor
learn that in its current form, It is wonderful for effortlessly acquiring and
sending out information.
You’ll know within a second or two if you want to open an email. You can
send a photo or video without digging for your phone. You’ll be quicker to
respond to text messages since they pop up in your field of vision and can
accept verbal replies. You can ask Google a question and get a reasonable
answer. I recently asked Glass, “What’s the capital of Belize?” while standing
at a Belize-themed food cart (it’s Belmopan).
On the other hand, many people believe Glass is some sort of virtual-reality
device. In fact, most of the time the display is turned off. You’ll get an audible
notification of when you receive new items, but you won’t walk around with
the screen on, because it’s both a distraction and a battery drain. Although
a future generation of Glass will undoubtedly trend toward reality-augmenting
capabilities, it’s not very good for that sort of thing right now.
Learning to Navigate
All actions in Glass are done by voice command, head motion, or touch pad.
When you start up Glass, you’ll see a screen with the time. A handful of Google
engineers call this the clock screen, but I’ve come to refer to it as the home
card (who can say if it will always contain a clock?), and will for the rest of
this book. A card is a single screen visible on the display, as the following
figure shows.
The big plastic piece of Glass is where all of the electronics are housed, as
you can see in Figure 1,An overhead view of Glass, on page 3. The back
portion is the battery pack and the middle part in front of your ear is where
the computer resides. The outermost casing is a touch interface called the
swipe bar.
If you tap the swipe bar on the side of your Glass while it’s in power-save
mode (the screen is off), you’ll start at the home card. From here, saying the
voice trigger “OK, Glass” out loud will open up a menu of commands, as
shown in the following figure.
The list scrolls off the page, which leads us to the head gesture. Vertical
scrolling in Glass is almost always performed by tilting your head up and
down. As you look down, the list will scroll up as though you were holding
up a dinner menu and perusing down it.
Saying any of the commands out loud will begin that action. The ellipses (...)
at the end of the command represent the remainder of the request. Valid
input is fairly intuitive.
If you need directions to Las Vegas, say “OK, Glass, get directions to Las
Vegas.” In that case, “OK, Glass” is the trigger, “get directions to” is the
command, and “Las Vegas” is the input.
If you have a contact named “Mom” in your list, you can be a good kid and,
assuming you’re paired to your mobile phone, start a phone call with “OK,
Glass, make a call to Mom.”
Voice commands and head-bobbling are only part of using Glass. The other
component is swipe-bar gestures. When you’re ready to close an active card,
you hold a single finger to the side and swipe down, as you see here.
To exit a process, such as ending a phone call, you can touch two fingers to
the swipe bar and swipe down. This is the close gesture, which goes straight
back to the home card and power-save mode. Most times you’ll use the single
swipe action, but when in doubt, try two fingers.
If you tap the side of your Glass again from the home card, you’ll see a menu
of options, not entirely unlike the voice-command menu. The difference here
is that you can bring up your menu choices without speaking, which is useful
in company meetings and movie theaters.
Timeline
From the home card, you can swipe forward, which will move your display
through your timeline, as you can see in the following image. The timeline is
a chronological listing of cards, each displaying a single cell of information.
That information is usually simple, be it an email, a past phone call or SMS
conversation, a Google search, or some information populated by a Glass
application, called Glassware.
For example, you can sign up for the Twitter Glassware that keeps you up-
to-date on new tweets. You can use the Android Glass app, which you see
here, but you can also visit http://google.com/myglass for the same options.
Now anytime someone sends you a tweet, it creates a new card in your time-
line, stamped with the time of creation.
If you tap the swipe bar while viewing the card, aka “tap the card,” you’ll see
a menu of options. These can be defined or customized with Glassware. If you
want to delete a tweet from the timeline, you swipe through to the end of the
menu list to the Delete action, and tap to choose it.
The action will pause for two seconds to give you a chance to abort. If you’re
really intent on letting it delete, it will signal success and be removed from
the timeline. On the other hand, if you wish to abort or leave the menu
entirely, swiping down vertically with one finger is the cancel or back com-
mand. Single-finger swipes along the swipe bar or down are the most common
gestures you’ll make.
If you start at the home card again and swipe the other direction, you’ll see
a set of non-timeline cards. There are relatively few cards on this side of the
home card, since they’re meant to be shortcuts. These are known as pinned
cards, often populated by the Google Now application and containing informa-
tion like the local weather or airline flight information. We’ll cover pinning
cards in Chapter 4, Building the Timeline, on page 41.
At the end of all pinned cards, you can see the settings card.
This is the center of all Glass-based configurations. You can scroll through
settings options like those in the following image.
Tapping on this allows you to join a Wi-Fi network and specify on-head
detection, debug mode, and other system settings.
There is plenty more to know about using Glass. If you need help, search the
wealth of information online or contact the Glass support team.
Glass Hardware
These hardware specs are good to be familiar with, especially if you had any
currently unattainable dreams of rendering highly detailed scenes on Glass
in real time or running 24 hours uninterrupted. The hardware just isn’t
powerful enough for that yet. The design is rather basic, as you saw in Figure
1,An overhead view of Glass, on page 3.
Glass currently does not use cutting-edge technologies, but rather combines
standard technologies in a cutting-edge manner. The following hardware details
were gathered from a Sparkfun-sponsored teardown,2 the blog post "Sensors on
Google Glass,"3 the GDK documentation,4 and Glass tech specs.5 Obviously any
of these specs can and likely will change with later versions, but I’ve listed them
here to give you an idea of what is packed into Glass’s small form factor.
One of the most interesting pieces on the list is the display. It requires very
high-definition LCOS (liquid crystal on silicon) projecting an image onto a
2. http://www.catwig.com/google-glass-teardown/
3. http://thecodeartist.blogspot.com/2013/05/sensors-on-google-glass.html
4. https://developers.google.com/glass/develop/gdk/
5. https://support.google.com/glass/answer/3064128?hl=en&ref_topic=3063354
prism, which reflects an image onto the retina. Despite the prism’s sitting
about an inch from your eye, you see the equivalent of a 25-inch high-defini-
tion screen quite clearly from eight feet away.
Glass Software
As with the shift from desktop to mobile-phone development, Glass presents
new challenges for programmers. Its limited touch interface means that you
have to consider other inputs, such as voice and head movements, to interact
with Glassware. Its small 640×360 display presents viewport problems even
greater than the average smartphone’s. In this book you’ll learn not only the
technical details of writing Glassware with the Mirror API, but also the prac-
tical tradeoffs you’ll have to consider.
For example, the built-in web browser effectively projects a portion of a website
in front of you, and you move your head to pan around the page. It’s as though
you’re looking at a large poster fixed in space, but you can view only a piece
at a time. This is one way the Glass engineers used the head-bobble interface
to solve the problem of a small display.
Mirror API
The Mirror API is focused primarily on manipulating and reacting to changes
to the Glass timeline. Your software communicates to the Mirror API, which
Google in turn uses to populate your users’ timelines in some way. All
The GDK’s purpose is threefold: First, to interface with the user or with devices
not provided by Glass Android or the Mirror API (for example, a notepad app
that pairs with a Bluetooth keyboard). Second, to allow natively installed
software that can run absent of an Internet connection (Mirror API timeline
manipulations require a Wi-Fi connection). Third, to create applications outside
the confines of the timeline (for example, a service that takes a picture when
the user blinks).
The reasons someone chooses the Mirror API over a GDK app are similar to
why a mobile-phone developer would choose a mobile-optimized web app over
a native app.
Wrap-Up
Navigating Glass is easy, but it does present new challenges for developers.
Its new form factor reduces the amount of information you can display on a
screen, and limits interaction to certain voice commands and touch gestures
(swipe forward, backward, up, or down). Bobble-head gestures present a new
dimension for interactivity, but will also require great care for programmers
and designers to use correctly—as with any new style of interface.
www.it-ebooks.info
CHAPTER 2
Since Glassware applications using the Mirror API require a web application
to generate content, we have to begin with the steps necessary to create a
web application. Unlike applications that are installed natively—the kind you
might download on iOS or Android—Mirror API apps are installed and operate
exclusively on a remote server.
But we get to take a shortcut. Rather than installing and configuring your
own server, we’ll take advantage of Google’s Platform as a Service (PaaS) called
Google App Engine (GAE). Using GAE, we can host our own Mirror API–based
Glassware for free, up to five million page views a month. Look at Figure
2,The actors in creating Glassware using the Mirror API, on page 14. At the
bottom is your application, which GAE will host.
You can interact with any approved user’s Glass device through JavaScript
Object Notation-encoded HTTP requests to the Mirror API. Google’s servers
handle the details of communicating directly with your user’s Glass data on
your behalf. But before you can start firing off requests that make your
Glassware tick, you’ll need two things: someplace to run your Glassware
code—we’ll be publishing code to Google App Engine—and authorization for
your application to read from or write to a user’s Glass data.
In this chapter we’ll tackle the first of those items by setting up and publishing
a GAE-hosted Java web application that we’ll use throughout the book. This
is the skeleton of our Glassware. Our project is called Lunch Roulette, which
will suggest a random lunch idea to any of our Glass users. It’ll start rather
basic, but as we move on it will become increasingly sophisticated, complete
with geolocation, restaurant suggestions, and fancy designs and images, and
will even allow users to call the restaurant (perhaps to make a reservation).
Platform as a Service
Google App Engine is Google’s PaaS. The idea behind all PaaS providers is to allow
developers to deploy web-app code to the provider’s infrastructure. PaaS handles
many of the operation details, like installation, deployment, and adding servers, so
you can focus on writing code. Although you could use other PaaS providers, such
as Heroku, we’ll stick with a full Google stack in this book.
Setting Up GAE
Before we dive into our Glassware, we’ll need to set up a Google App Engine
application. Happily, any Google account, such as Gmail, can be used to
create one.
2. Enter a unique Application Identifier (app ID), that will be your subdomain
at GAE’s ‘appspot.com‘ domain—for example, ‘glassbooktest‘.
5. Select High Replication under Storage Options. This is the default and
future-proof storage engine, since Master/Slave is being deprecated in
GAE.
With everything set up, you can visit your web app. Its URL is your app ID
prepended as a subdomain of appspot.com. Since the example ID in this book
will be glassbooktest, you would visit https://glassbooktest.appspot.com.
The page will output Error: Server Error. This is expected since the app location
exists but nothing has been deployed.
are some plug-ins. It can also be a bit of a memory hog, so don’t go installing
this on your Raspberry Pi. No matter the power of your system, these steps
can take a while to download and install.
First, ensure you have the Java 7.0 Java Development Kit (JDK) installed on
your machine. Any JDK type (OpenJDK, Oracle, and so on) should work,
though I tend to stick with the Oracle release. Next, install Eclipse for your
operating system.1 All examples in Part One are based on Eclipse version 4.2
(Juno).
The first time you launch Eclipse it will have to create a workspace. This is
just a directory that will house all projects created from the IDE, and some
other working files.
Once Eclipse is finished launching, we need to install the GAE plug-ins. Select
Help in the top menu bar, then Install New Software. A window will pop up
to add available software; it should look something like Figure 4,Adding the
GAE plug-ins to Eclipse, on page 17.
We need to enter a Work With URL that tells the IDE where to find the plug-
ins: http://dl.google.com/eclipse/plugin/4.2. If that does not work, visit the Google
Plugin for Eclipse (https://developers.google.com/eclipse/) website to find installation
instructions, which will provide a correct URL.
Several plug-in options will populate. You’ll need only the following:
Click Next, then wait a bit while your tools download and install. You may
have to agree to some licenses and restart Eclipse after install.
With your tools installation complete, you should find a little Google logo in
the lower corner of your IDE’s workspace. Click it. A window will pop open
requiring you to log in using the same Google account you used to create
your GAE application. If you have multiple Google accounts, ensure you use
the correct one.
1. http://developer.android.com/sdk/index.html
timeline with lunch suggestions. But in this first pass we’ll create a simple
web app that outputs a random lunch suggestion every time we refresh the
web page.
It will launch a web-app project wizard, where you can enter a project name
and package. Enter LunchRoulette and test.book.glass, respectively. Uncheck
Use Google Web Toolkit (we won’t use it anywhere in this book), and ensure
Use Google App Engine is checked. Also check Generate Project Sample Code,
since this will be the basis of our Lunch Roulette project. Click Finish after
your setup looks like the one in Figure 6,Your setup should look like this, on
page 19.
You should now have a project in your Eclipse sidebar called LunchRoulette
that contains some generated Java web-app files. The files worth looking at
are LunchRouletteServlet.java and war/WEB-INF/web.xml. The LunchRouletteServlet.java file
will contain the code we’re going to write and the web.xml file contains the
metadata for the web app—specifically, it defines which URL gets routed to
which servlet.
We’ll modify the generated Java servlet to accept HTTP GET requests at
/lunchroulette and reply with a random lunch suggestion, such as Italian, Chi-
nese, American, or whatever you add to the list. To output a random sugges-
tion, replace the generated LunchRouletteServlet class with the following code.
public class LunchRouletteServlet extends HttpServlet
{
/** Accept an HTTP GET request, and write a random lunch type. */
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException
{
resp.setContentType("text/plain");
Finally, create a new class called LunchRoulette and define a new getRandomCuisine()
method.
chapter-02/LunchRoulette/src/test/book/glass/LunchRoulette.java
public static String getRandomCuisine()
{
String[] lunchOptions = {
"American", "Chinese", "French", "Italian", "Japenese", "Thai"
};
int choice = new Random().nextInt(lunchOptions.length);
return lunchOptions[choice];
}
This file will contain most of the custom code we’ll create as we build our
Lunch Roulette app throughout the book.
In this pop-up (so many pop-ups!) enter your GAE application ID and click
OK.
You should be back at the deployment wizard, so now you can click Deploy.
You’ll see a lot of text running through your console as it tries to deploy. If
all goes according to plan, you’ll see the log message “Deployment completed
successfully.”
------------ Deploying frontend ------------
Preparing to deploy:
Created staging directory at: '/var/folders/lz/s8dy1m9x0r9g2z7zt4ktpsgr0000gn
/T/appcfg6810984979425725784.tmp'
Scanning for jsp files.
Scanning files on local disk.
Initiating update.
Cloning 2 static files.
Cloning 22 application files.
Deploying:
Uploading 5 files.
... snip ...
Deploying new version.
Closing update: new version is ready to start serving.
Uploading index definitions.
If anything goes wrong, the log will give a hint as to the problem. If your
deployment fails, ensure you’re logged in and that you’ve entered the correct
application ID. Many other problems could arise here. The Glass Developers
community and Stack Overflow are excellent places to find help.2,3
To verify everything is deployed, visit your GAE root URL (mine was
‘https://glassbooktest.appspot.com/‘). You’ll be greeted by an index page
(generated for you by the GAE plug-in) with a link to your ‘LunchRoulette‘
servlet, like in the following figure.
Click on the link to harvest the fruits of all of your hard work: a random lunch
type—you should feel proud! Refresh to get a new lunch option.
Fancy Templates
So far our servlet has only sent plain text to the browser. Rather than writing
HTML inline or using Java Server Pages—the common alternative to servlets
in Java—we’ll introduce a simple templating library called FreeMarker.4
2. https://developers.google.com/glass/community
3. http://stackoverflow.com/questions/tagged/google-mirror-api)
4. http://freemarker.sourceforge.net/
Download the GAE-compatible binary FreeMarker .jar, and drag it into your
project’s war/WEB-INF/lib directory. If the JAR doesn’t show up as one of the
Referenced Libraries, click the project’s properties, select Java Build Path,
and under Libraries choose Add JARs… then drill down to war/WEB-INF/lib,
choosing the JAR.
Then change the servlet’s doGet method to populate a random food and render
the template, rather than simply printing out the string. We also need to set
the content type as HTML.
chapter-02/LunchRoulette/src/test/book/glass/LunchRouletteServlet.java
public class LunchRouletteServlet extends HttpServlet
{
/** Accepts an HTTP GET request, and writes a random lunch type. */
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException
{
resp.setContentType("text/html; charset=utf-8");
resp.getWriter().append(html);
}
}
chapter-02/LunchRoulette/war/WEB-INF/views/web/cuisine.ftl
<!doctype html>
<html>
<head>
<title>Lunch Roulette</title>
<style>
h2{ color:#db1; }
body{ background-color:black; color:white; }
</style>
</head>
<body>
<article>
<h2>Your Lunch</h2>
<strong>${ food }</strong>
</article>
</body>
</html>
With our code in place, now is a good time to test it. You don’t have to deploy
the application to test these changes. Click the run icon in Eclipse (it looks
like a green triangular play icon), or choose Run As -> Web Application. This
runs a small GAE environment locally—basically, a Java web-app server.
Then visit http://localhost:8888/. This is useful in later chapters, since you can
test your Glassware without deploying your application to GAE.
If all works according to plan, you should be redirected to the Google autho-
rization page, requesting access to view account information, your Glass
timeline, and your Glass location.
Wrap-Up
I promise we’re making great strides toward our first Glassware application.
We activated our Google App Engine service, set up the development environ-
ment, generated a web application, and deployed it to GAE. We also made a
small step toward eventually customizing our Glass content with dynamically
rendered HTML.
Soon we’ll populate Glass timelines the world over with delicious lunch sug-
gestions in Chapter 4, Building the Timeline, on page 41. But first, we must
expand our existing web-server code to allow a user to log into the system.
This is the crux of the next chapter.
In this chapter we’ll leverage our GAE application to hook into the Glassware
application pool, allowing users to authorize our application. This is the last
step necessary to create real Glassware.
In any web-based application (which all Mirror API applications are) the first
step of a custom user experience is knowing who the user is. This need not
involve personal information like a name or email address; it need only consist
of some token that a user can share with the web application to identify her-
self.
Security, such as a password or OAuth 2.0, is to ensure that only that user
has access to her own personal information, be it credit-card details or a
collection of family photographs. We’ll use Google’s OAuth 2.0 interface for
the rest of this book. OAuth can be quite complex, and sticking with one
implementation for one purpose will let us charge through this necessary but
sometimes mind-melting topic.
Google has policies to help make this agreement more explicit. You can and should
read the details here: https://developers.google.com/glass/policies. In sum, allow users to
manage their own data, take proper security measures, and don’t ever share users’
data.
Like all API activations, you access this through Google’s APIs Console. If you
notice a message at the top of the screen that says something like “Try the
New Cloud Console”, click that. These steps won’t work for the old API console.
Also please note that Google is still in the midst of creating the new Developer
Console, and some of these steps are liable to change after publication.
2. Select APIs & Auth, then toggle the Google Mirror API to ON.
1. https://console.developers.google.com/
“Come on, Rad! Hop in! Show us where Koku is and we’ll soon
have him loose!” cried Tom, as he motioned to the rear of the
runabout, for he and Ned were seated in front.
“How is Koku taking being tied up?” asked Ned while the colored
man climbed in as quickly as his rheumatic joints would allow. “Is
Koku mad?”
“Mad? He done froth at de mouth!” cried the old servant. “By
golly, I wouldn’t like to be de one whut done tied him up after he gits
free!”
“Koku would be one of the best fellows in the world to take along
on the search for the robbers, Tom,” suggested Ned. “He’ll be so
angry he can easily handle half a dozen with one hand—if there
should prove to be that many in the gang.”
“Shouldn’t wonder but what there are more than that in the plot,”
agreed Tom. “It’s a queer game! But come on. We must help Koku.
Where is he, Rad?”
“Over by Lake Carlopa—dat place where you and me used to go
fishin’.”
“You mean Chestnut Point?”
“Dat’s de place, Massa Tom.”
“A lonely region,” remarked the young inventor, as he started the
runabout. “They couldn’t have picked out a better—or rather, a worse
—place to leave poor Koku. How’d you happen to think of looking
there, Rad?”
“Well, Massa Tom, I t’ought maybe Koku might go there of his
own se’f. Onct I kotched a big fish there, an’ I was tellin’ him ’bout it.
He always said he could kotch a bigger fish’n whut I did. So I t’ought
maybe he was tryin’ to beat me, an’ maybe de robbers didn’t tuk him
after all. So I looked an’ I done see him tied to a tree!”
The run to Chestnut Point did not take long, and, following the
directions of Eradicate, Tom guided his machine along a lonely road.
They had traversed this a short distance when Ned cried:
“Hark!”
“What did you think you heard?” asked Tom, shutting off the
motor to render the machine silent.
“Some one calling,” answered Ned. “Listen!”
A loud voice was borne to their ears by the wind, and Tom had no
sooner heard it than he cried:
“That’s Koku! And he sure is mad!”
The giant was like an enraged bull, but so securely was he bound
to a tree with many strong ropes and straps that even his great
strength was of no avail, especially as he was so cunningly bound
that he was unable to exert his full strength.
“Good you come, Master Tom,” grunted Koku, as he saw his
friends approaching in a run. “You friend of mine from now on, Rad—
you bring help to me.”
“Cou’se I’s you’ friend,” chuckled Eradicate. “De only time when
we has any disputations is when you tries to take my place wif
Massa Tom.”
It was the work of some time for Ned and Tom, even with their
sharp knives, to cut the straps and the ropes, the knots of which had
proved too hard for the colored man to loosen. Then, working his
great arms and striding up and down amid the trees to restore his
stagnant circulation, the giant cried:
“Where are ’um? Where are ’um mans that tied me? Once I git
’um—I mince pie ’um!”
“Guess he’s heard the expression ‘make mince meat of them,’ ”
remarked Ned to Tom.
“Very likely. But I’ve got to get him quieted down so I can
question him. He will be the best one to give us clews by which we
may trace these fellows.”
Accordingly Tom talked to his giant helper and finally got an
account of what had happened. Tom could do more with Koku and
understand his peculiar English better than any one else. Also Tom
knew something of the giant’s own language.
Gradually a coherent story emerged. Koku had been left on
guard the previous night in Tom’s private office building, following the
attack on the young inventor. The early part of the evening had
passed without anything to disturb the giant’s sleep. Later, however,
the alarm bell over his bed rang. Tom had not trusted altogether to
his giant remaining awake when on guard, and, as old readers know,
the whole place was wired in burglar alarm fashion.
So that, even though the door was opened with a skeleton key,
as was proved later to have been done, the swinging of the portal set
off one signal, the wire to which had remained intact, and Koku
awakened.
He had been awakened some months before by the alarm bell,
but that time it was Tom himself who entered the place late at night
to make notes on a certain plan before he should forget the idea that
occurred to him. Tom forgot about the burglar alarm, and set it off,
bringing Koku running with a gun in his hands.
Of course Tom laughed at the incident, but Koku now
remembered this, and, thinking it might be another false alarm, he
did not at once rush to the floor below, but proceeded cautiously. If
the intruder should prove to be some one with a right to enter, Koku
would go back to bed again.
Going down softly, and looking in the room where the big oak box
was kept, the giant saw several strange men trying to force the
locks. This being beyond them, one of the men had cried, as Koku
understood it:
“Let’s take the whole shooting match along! The Blue Bird will
carry it and we can open it in the woods.”
So they had picked up Tom Swift’s chest of secrets and carried it
out of the office. Even then Koku did not give the alarm, for his brain
did not work as fast as the brain of an ordinary person. Then, too,
the giant thought he had plenty of time, and could, when he got
ready, sweep the robbers off their feet and take the chest away from
them.
But he delayed too long. Following the men—there were eight of
them, he counted on his fingers—Koku went out of the office building
into the darkness. The men carried the chest to a large automobile
that was waiting in the road, the motor running and the lights off.
Then, just as they loaded it in and Koku was about to spring on
them, the men discovered his presence and jumped on the giant
before he could get into action.
Even a little man will have the advantage of a much larger and
more powerful fellow if the little man gets started first, and this was
what happened in the case of Koku. Besides, there were eight of the
robbers, and though under some circumstances Koku might have
been able to fight eight, or even ten men, taken as he was by
surprise, he was knocked down.
He struggled, but the men threw “something into his face” that
stung and made him “feel funny” and he was gagged, bound and
lifted into the auto, though his weight made the men “grunt like pigs,”
as the giant expressed it.
So the thing happened, and Koku, helpless, a little stunned, and
silent, was driven off in the night, no struggle at all having taken
place in the office.
Where he was taken the giant did not know in the darkness. But
after a while he was lifted out of the car and tied to the tree where
Eradicate found him.
“But what became of the robbers and Tom’s chest?” asked Ned.
“ ’Um robbers go off in Blue Bird with chest of secrets,” answered
the giant.
“What does he mean—Blue Bird?” asked the manager.
“It’s a big aeroplane painted blue,” explained Tom. “The men had
it hidden in a cove on the lake. It must be a hydroplane, though
possibly it’s a combination of both types of machine. Koku had a
glimpse of it because the robbers used pocket flashlights. They put
the chest in the blue aeroplane and soared off with it. Koku said he
could hear the throb of the motors for a long time after they were
gone.”
“What’s the next thing to be done?” asked Ned. “We can’t do
anything here, and it’s getting late. Did Koku see any of the faces of
these fellows?”
“They all wore masks,” Tom said. “Yes, Koku, what is it?” the
young inventor asked, for he noticed that his giant wanted to tell him
something in addition.
Followed then more of the queer, jumbled talk of the big man,
who, now and then, used some of his own words, which Tom alone
could translate. Then came silence.
“He says,” interpreted Tom, “that one of the men walked with a
slight limp and had a queer habit of throwing his left elbow out from
his side.”
“Limping! Throwing out his elbow!” excitedly cried Ned.
“Does that mean anything to you?” asked Tom.
“Does it? I should say it does. Why, that’s the very thing Renwick
Fawn does!”
“Renwick Fawn!” exclaimed Tom. “You mean——”
“The man who accused my father of taking the Liberty Bonds!”
fairly shouted Ned. “I always thought that fellow was a crook, and
now I know it. Tom, he’s in with the scoundrels that robbed you!”
“Maybe,” assented the young inventor. “I wouldn’t put it past him,
since I’ve had a look at his face. But if this is the case, we have
several clews to work on now, Ned. The limping man with the queer
elbow action, the blue aeroplane, and some other things that Koku
told me. Let’s go back and get busy!”
CHAPTER XXI
SCOUTING AROUND
Fairly well satisfied that he had secured some clews that would
be of value to him, Tom Swift hurried home with Ned, Koku and
Eradicate in the electric runabout. On the way the giant recovered
somewhat from the rough treatment accorded him by the robbers,
and talked of what he would do to them when he caught them.
“You must be hungry,” suggested Ned, as they neared Shopton.
For Koku had been taken away the previous midnight and evening
was now coming on again.
“Me eat ten loaves of bread!” cried the giant, opening wide his
enormous mouth.
“We’ll give you something else, too!” chuckled Tom. “But I know
poor Mrs. Baggert will almost faint when she sees you begin to eat.”
The giant’s appetite was always a source of wonder to the
housekeeper, and now, starved as he was by his enforced fast, it
might reasonably be expected that he would clean out the pantry.
Tom had the foresight to stop and telephone word to Mrs. Baggert of
the situation, so she sent out and got in plenty of food before the
wayfarers returned. Thus was Koku provided for.
“Well, Ned, let’s get together and talk this thing over,” suggested
Tom to his manager, leaving the giant still eating, long after the
others had finished. Eradicate, true to his promise to be friends with
the big man, remained to help serve him.
“Yes,” agreed Ned, “we had better make some plan to work on.
But this discovery that Renwick Fawn is in the plot rather surprises
me.”
“I must see if Mr. Damon knows anything about him in this
connection. He may have heard Blythe speak of him.”
Mr. Damon was communicated with over the telephone, and after
several queer “blessings” announced that, as far as he knew, Fawn
was a stranger to Mr. Blythe.
“He doesn’t know anything of Blodgett either,” Tom told Ned,
recalling the conversation Mary had overheard in the restaurant.
“Then we’ll have to tackle Fawn on our own account,” said Ned. “I
know where he lives. Shall we go to his house and ask for him?”
“What shall we say to him if he’s at home?” Tom wanted to know.
Ned thought for a moment and replied:
“We can ask him, for a starter, if he has recovered any of the
Liberty Bonds he says my father took. Then, after that opening, you
can mention the theft of your box and ask if Fawn thinks there is any
connection between the two.”
“Then what?” Tom inquired.
“Well, if things turn out the way we expect—I mean if this Fawn
has really had a part in the robbery at your place—he’ll get confused
and maybe give himself away. That’s our one hope—that he will give
himself away.”
“It’s worth trying,” decided Tom, after a little consideration. “Come
on.”
A little later in the evening the two young men set off in a small
gasoline car to call at the home of the suspected man. Ned had had
occasion to go there before some time since, months prior to the
accusation against Mr. Newton.
But it was with some feelings of apprehension and with
wonderings as to what they had best say to the man when he saw
them that Ned and Tom walked up the steps of the Fawn home.
A maid answered the door, and when they said they had called to
see Mr. Fawn she remarked:
“I think Mr. Fawn is not at home, but Mrs. Fawn is. Please come
in and I will tell her you are here.”
Mrs. Fawn, a small, pale, unimpressive woman, came timidly into
the room where the boys waited.
“You wanted to see my husband?” she asked, and Tom jumped
at once to the conclusion (in which Ned later joined) that she knew
nothing of the man’s peculiar activities. Their feeling that he was a
brute and a bully toward her was afterward borne out by facts.
“We have some business to transact with Mr. Fawn,” stated Ned.
“But the maid said he wasn’t at home.”
“No, he isn’t,” answered Mrs. Fawn, and the boys did not doubt
her. “He has gone to Chicago on business. At least I think it is
Chicago,” she added. “He goes to so many places I sometimes
forget. But I know it was out West.”
“Well, if he’s that far off, I guess we can’t see him to-night,”
returned Tom with a smile as he arose to go. “When did he leave
town?”
“The day before yesterday,” answered Mrs. Fawn.
Ned had not given his name, and though Tom had mentioned his,
he did not believe Mrs. Fawn knew enough of her husband’s
business to connect her callers with the bond accusation against Mr.
Newton.
But the two young men glanced sharply at each other when Mrs.
Fawn spoke of her husband having gone to Chicago two days
previous. If that was the case he could hardly have been engaged in
the theft of Tom’s strong box.
“Do you want to leave any word for Mr. Fawn when he returns?”
asked his wife.
“Thank you, no,” answered Tom. “It wasn’t important. We’ll see
him when he gets back.”
When they were outside Ned asked:
“Well, what do you think now, Tom?”
“I don’t know what to think. Koku is pretty sharp. When he says
he saw a thing you can make up your mind that he did. Of course it’s
possible there may be two men who limp and throw out their left
elbows, you know.”
“It’s possible, but not very probable,” answered the young
manager. “I believe Fawn is guilty, but his wife may not, and very
likely doesn’t, know anything about it. She’s a meek little lady.”
“Yes, indeed,” agreed Tom. “Well, we’re stuck for the time being.
However, to-morrow is another day. Something may turn up then.
Anyhow, even if it doesn’t, I’m going to start out.”
“Start out where?” Ned wanted to know.
“To look for that blue aero-hydroplane. I’m going to scout around
in the Blackbird and see if I can’t get on the trail of the fellows who
have my chest of secrets.”
“I’d like to go with you.”
“Wouldn’t think of taking off without you, old scout!” cried Tom.
He guided the car down the street and out on a wide avenue,
going along at a steady pace and with such an evident object in view
that Ned asked:
“Where are you heading?”
“I thought I’d stop at the Nestors’ a minute,” answered Tom.
“Then let me out here and I’ll take a trolley home,” said Ned.
“Let you out here! What’s the idea?” cried Tom.
“Well, you’re going to call on Mary, and——”
“Forget it!” laughed Tom, clapping his chum on the back. “This is
a sort of joint call, and you’re coming in. Mary isn’t fussy that way,
and she always likes to see you.”
“Thanks,” murmured Ned.
The two young men were no strangers in the Nestor home, Tom
especially; and soon the whole family was in conversation. Tom
mentioned the fact that he and his chum had just called on Mr. Fawn
but found that he had left for the West two days before.
“Left for the West!” exclaimed Mr. Nestor. “That’s queer!”
“Why so?” Tom asked.
“Because I saw him in town yesterday morning. And he couldn’t
have been going to Chicago.”
“Are you sure?” inquired Ned.
“Of course. I know the man as well as I know you. He was
limping along, tossing his left elbow out every now and then as he
has a habit of doing.”
Ned and Tom glanced at one another. If this was the case it
would explain matters. Fawn may have told his wife he was leaving
for Chicago, and even have packed a bag to go. But he went to
some other place and remained about Shopton long enough to take
part in the robbery that night.
Mr. Nestor’s mention of the peculiar gait of the man and his habit
of tossing his left elbow away from his body while walking or talking
was almost positive proof that there could be no mistake.
But Tom was not yet ready to let it be known that Fawn was
caught in a falsehood. There were many more points to be cleared
up before the affair was on the way to be solved. So, passing the
matter off as though it did not amount to much, murmuring that
possibly he had misunderstood Mrs. Fawn, Tom turned the talk into
other channels.
The chums left the Nestor home near midnight, Mary expressing
her indignation at the loss inflicted on Tom and asking if she could
not do something to help.
“I’ll let you know if you can,” Tom told her as he pressed her
hands.
For a few minutes Tom and Ned rode on in silence, each busy
with his thoughts, and then Ned asked:
“Well, Tom, what do you make of it?”
“You mean about Fawn not going to Chicago at all?”
“Yes.”
“Well it means he’s a trickster surely, but more than that. He’s in
the plot, of course. And I’m beginning to believe that it’s bigger than I
thought. Fawn and Barsky—both in the same town, both probably
working together against dad and me. It was a sorry day when I let
that so-called Russian into my shop!”
“It surely was,” agreed Ned. “But it’s too late to think of that now.
What is the next move? I want to get my hands on Fawn, as well as
on the others.”
“We start scouting to-morrow morning!” decided the young
inventor. “It oughtn’t to be hard to pick up the trail of this blue
aeroplane. I had some inquiries made around Lake Carlopa, and she
seems to have headed west. That, naturally, would be the best place
for the robbers to go—plenty of open places to land, and with widely
scattered cities and towns they wouldn’t run so much risk of being
captured. We’ll start scouting in the morning.”
Accordingly the Blackbird was made ready. This craft was not as
small nor as speedy as the Hummer, but she would carry three, and
Tom decided to take Koku along to identify the robbers if possible.
“Good luck, Tom!” called his aged father, as he was ready to take
off the next morning. “Bring back that chest!”
“I’ll do my best!” was the answer.
CHAPTER XXII
A STRANGE MESSAGE
Barton Swift was the true father of his energetic son, and Tom
inherited his qualities from his father. Which is to say that in his youth
Barton Swift had been fully as active and quick as was now the
young inventor.
Though age and illness had to some extent dimmed and
enfeebled the powers of the man, still it needed but this spark—that
strange telephone message—to galvanize him into action. After the
first shock of hearing so unexpectedly about the stolen chest of
secrets, Mr. Swift was ready to take active measures to trace the
voice coming out of the machine.
“What’s that you say?” he asked, nerving himself to carry on an
ordinary conversation about a most extraordinary topic. “Who are
you and where are you?”
“Don’t you wish you knew?” came back the challenging inquiry.
“Are you ready to talk business?”
“Of course I am,” answered Mr. Swift. “We want that chest back,
and we’ll pay any reasonable amount.”
“I’m not saying the amount will be reasonable,” was the reply, and
emphasis was laid on the last word. “But you’ll pay our price or you
don’t get the chest. And I warn you that if you try to communicate
with the police or set the detectives on our trail we’ll immediately
break off negotiations.”
Trying to get in touch with the police was just what Mr. Swift was
then doing. Ned Newton’s father had entered the office, and, seeing
him, Mr. Swift at once took pencil and paper from his desk and while
he talked in a rather general way with his unseen listener, he jotted
down a few words, explaining matters and suggesting that Mr.
Newton go to another telephone to learn from the central operator
where the mysterious call was coming from.
There were several trunk telephone lines running into the Swift
office, so it was a comparatively easy matter for Mr. Newton to go to
another instrument to get the information needed.
Meanwhile Mr. Swift was holding the other man in conversation.
Having started Mr. Newton to ferreting out some information, the
aged inventor asked:
“How much do you want to return the chest and how can I get in
touch with you?”
“If you will take fifty thousand dollars in unmarked bills, make a
bundle of them and bring them——”
But at that moment the criminal either heard something—perhaps
the movements of Mr. Newton—or he suspected something, for he
sharply broke off what he was saying and cried:
“It’s all off! You’re trying to double cross me! Now you’ll never get
your chest back!”
There was a click which told that the distant receiver was hung
up, and then the line went dead.
“Wait a minute! Wait just a moment! I want to talk business with
you!” cried Mr. Swift, rapidly moving the hook of the receiver up and
down.
But it was too late. Only silence ensued until finally the operator,
attracted by the flashing light which resulted when Mr. Swift moved
the hook, asked:
“Number, please?”
“I was talking to some one, but I was cut off,” said the inventor.
“Can you get them back for me? It’s important.”
“What number were you talking to?” the girl asked.
“That’s just what I want to know,” said Tom’s father.
“I’m sorry, but if you don’t know the number I can’t ring it for you.”
Mr. Swift knew only too well that this was the case. It was not the
girl’s fault—it was the fault of the system, and not so much the fault
as the limitation.
“If I had only had Tom’s photo-telephone attachment hitched on
here I could have seen who it was I was talking with,” lamented Mr.
Swift. “How about it, Mr. Newton, did you succeed in getting any
information?” he asked, as the latter came away from the second
instrument.
“The manager said he would try to trace the call for you,” was the
reply. “But I didn’t have much time. Whoever it was got suspicious
too quickly.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookfinal.com