Getting Started
Welcome to the exciting new world of Google Glass! If you are reading this book, either you are most likely a Google Glass owner or you do not own Glass yet but are intrigued by it. Chances are that you are a mobile, web, or enterprise application developer looking for the next big thing and platform and trying to understand what great apps can be built on the new Glass platform. Or maybe you just want to understand the potential of Glass and see what Glass can truly do.
Before you start the journey of Glass development, let’s first discuss some big questions in this chapter: Why Glass? What is Glass and Glassware? What can Glass do? What kinds of Glassware can you develop? I’ll also cover Google’s Glassware Policies and resources for Glass development at the end of this chapter.
The first generation of iPhone was released in June 2007, and Apple’s App Store was launched a year later. Android Market (renamed to Google Play later) was released in October 2008. It is absolutely amazing how many successful apps and companies have been built on and for the iOS and Android platforms.
Could Google Glass be the next big thing, in terms of mobile computing platform? Nobody knows for sure. But the attention that Glass has garnered in 2013 and 2014 is bigger than any other mobile products except iPhone or iPad, so here are several questions to ask yourself:
Note You may want to create an alert with the query google glass at www.google.com/alerts to get daily e-mail updates when there are any new search results for that query. As of May 2014, there are many exciting new results every day. Also, you can check out the web sites for the Glass community and developers detailed in the “Resources” section later in this chapter.
So, if you want to bet on Glass yourself and plan to learn about Glass development, this book is right for you! My goal is to reduce your learning curve as much as possible by providing clear and concise tutorials with fully tested samples for every topic in Glass development.
Glass is a new, potentially paradigm-shifting mobile computing platform, or wearable computer, developed by Google. Glassware is the term for the apps that developers build to run on Glass.
According to the Wikipedia page at http://en.wikipedia.org/wiki/Google_Glass, Glass began testing in April 2012 and was further demonstrated by Google founder Sergery Brin in June 2012 at Google I/O that year, where attendees were invited to the Glass Explorer Program. Glass was first available to testers and developers in early 2013 through the program; people who were interested in buying the device for $1,500 were required to tweet a message using #ifihadglass specifying how they intended to use Glass if they had it. The people who were selected by Google and went to buy Glass are called the Glass Explorers. In October 2013, those first explorers received e-mails from Google saying they could invite up to three people to join the Glass Explorer Program. The invited people would then receive an e-mail from Google with information on how to order Glass and become new explorers. Weeks after that, the new explorers also received an e-mail from Google stating that they could invite up to three more people. People can also go to the Glass web site and register their e-mails to request Glass from Google.
On April 15, 2014, Google made the Glass Explorer Edition publicly available for purchase, but only for that day. By the next day, all five Glass models (Charcoal, Tangerine, Cotton, Shale, and Sky) sold out. In May 2014, anyone can become a Glass Explorer by purchasing the Glass Explorer Edition at http://www.google.com/glass. With the anticipated consumer version release date coming in late 2014, it should become cheaper for developers and others to get Glass.
In case you don’t have Glass yet, just search for google glass at http://images.google.com to see how it looks. Glass keeps getting updated, so for an update of how it looks, you should check out www.google.com/glass/start/how-it-looks/.
To effectively use Glass and develop apps, you need to understand the timeline, which is the Glass user interface with which the user interacts with Glass. You should definitely check out https://developers.google.com/glass/design/ui to get a general idea of how the timeline works.
Here’s a quick overview of how you use Glass: After your Glass is turned on, you can either tap the glass or tilt your head up to go to the home screen, also called the OK Glass screen, where you see the words ok glass with the current time. There you can either tap Glass again or say “OK Glass” to enter the voice menu, which includes the actions Google, Take Picture, Record Video, Get Directions, Message, Video Call, Take Note, and other Glassware you have added. If you don’t tap or speak to enter the OK Glass menu, you can swipe Glass forward or backward on the touchpad to see the timeline cards, and on each card, you can tap to see its specific menu actions. You may also want to check out Google’s video of the basics of how to use Glass at www.youtube.com/watch?v=4EvNxWhskf8.
Note The order of the voice menu actions after entering the OK Glass screen for the Glass XE 16 update (released on April 15, 2014) and later is different from that for the Glass XE 12 update (released in December 2013). XE 16 or 17 sorts the menu actions by use frequency and recency, while XE 12 and older show the actions always in the same order.
Before late November 2013, there was only one official way to develop Glassware: the Mirror API way. Basically, you build web-based services that talk to Google’s cloud API, which in turn talks to Glass. Glassware built with the Mirror API can send updated information to Glass, subscribe to notifications of when users take actions on your updated information or when their location changes, and let users share information with others or other Glassware.
While the Mirror API was the only official way to develop Glassware before November 2013, since Glass is based on Android (some people think of Glass as just another Android device), early Glass developers actually were able to develop and test native Android-based Glass apps—with a little hack, of course. You’ll see in some projects of this book that this hacky sprit will continue to solve some hard problems. After all, we’re called Glass Explorers, and we’re supposed to do something officially not quite ready.
It was not until the release of the Glass Development Kit (GDK) Sneak Peak Rev. 1 on November 20, 2013, that the power to developers was officially presented. The GDK is built on top of Android, with rich and fuller user interaction that, unlike the Mirror API, does not always require network connectivity. Imagine that you can run OpenCV, a popular and powerful open source image processing library, or optical character recognition (OCR) completely in your Glass. You can also have access to low-level Glass hardware with the GDK. Unlike the Glassware built with the Mirror API, which runs on a server, the GDK Glassware runs natively on Glass. This book is mainly focused on the GDK but will also cover the Mirror API and how it can interact with the GDK in a complete but quick way.
Note The GDK Sneak Peak was based on Android 4.0.3 (API Level 15). On April 15, 2014, the next major GDK update, called the Glass Development Kit Preview, based on the latest Android 4.4.2, was released. This massive version bump means a lot to developers because they can now use APIs available for Android API Levels 15 up to 19. For example, the important Bluetooth Low Energy APIs were introduced in Android 4.3 (API Level 18), so they were not available with the GDK Sneak Peak (Android 4.0.3, API Level 15) but are available now with the GDK Preview (Android 4.4.2, API Level 19).
What Can Glass Do?
There are a lot of things Glass already can do and some other things you may not even know it can do.
Feature-wise, Glass offers the following built-in features:
Application-wise, you can use Glass to accomplish tasks such as the following:
For a complete list of active Glassware available for you to install on Glass, visit https://glass.google.com/u/0/myglass.
From a developer’s perspective, you can build all kinds of apps for Glass with the GDK and the Mirror API, such as the following:
You’ll see lots of working sample code related to the previously mentioned apps throughout the book, and depending on whether you’re an end user or a developer, you can either install and use the apps developed in the book or make further improvement and use them in your own apps.
Finally, here are some important quick tech specs on Glass:
You should visit https://support.google.com/glass/answer/3064128?hl=en for the complete tech specs and https://developers.google.com/glass/release-notes for the detailed release notes.
What Kinds of Glassware Can You Develop?
Before November 2013, the only official way to develop Glassware was using the web-based Mirror API. In November 2013, Google officially released the native Glass Development Kit.
Mirror API–Based Glassware
Mirror API–based Glassware consists of web-based services developed with the Mirror API. You can use many programming languages—on Google’s web site (https://developers.google.com/glass/samples/mirror) , sample start projects in Java, PHP, Python, Ruby, .NET, and Go are provided—to develop such web services to interact with the Mirror API running on Google’s server, which further interacts with your Glass on behalf of your Glassware. Figure 1-1 illustrates these interactions.
Figure 1-1. Interactions between your Mirror API–based Glassware, Google Mirror APIs, and Glass
Before the GDK, the timeline consisted of only static cards; the other type of cards are live cards and will be covered in the next section. Cards are the core of the Glass user experience. The size of each card, static or live, is 640 pixels in width and 360 pixels in height. Static cards can display text, images, videos, and HTML content.
Actions that can be completed on timeline cards include creating, updating, deleting, getting, listing, and patching. You can also associate menu items with timeline cards to let users perform built-in actions and/or your app-specific actions.
Timeline cards can also be shared with another person or Glassware. This is accomplished via subscribing to timeline notifications (using the Mirror API, of course). After the subscription, whenever a user selects a menu item or shares a timeline card content, or there is any insertion, deletion, and update in the timeline, the Mirror API can send notifications to your Glassware via a callback URL (to your Glassware web service) specified in the subscription API call. This is called timeline notification.
The other type of notification is location; you can get users’ location updates about every ten minutes after subscribing to the notification. You may also request for the location information for a specific timeline card or attach a location and menu item to a timeline card so the user can navigate to it when choosing the menu item.
One powerful feature of the Mirror API is that you can launch native GDK apps from a static card.
That is all you can do with the Mirror API. On one hand, you can build amazing services with the building blocks offered by the Mirror API. Here are some examples:
On the other hand, there is some serious limitation of the Mirror API in terms of what kinds of Glassware you can build with it: The timeline cards created via the Mirror API can’t access the camera, sensors, and other low-level hardware, and an online web server and always-on network connectivity are required for most of the application features. Enter the more sophisticated world of GDK Glassware.
The GDK is an Android SDK add-on that you can use to build powerful Glassware that runs directly on Glass. (Remember, the Mirror API–based Glassware runs on your own web server and interacts indirectly with your Glass via Google’s API server.)
Most of the Android APIs and Java language features can be used directly in Glass, which grants your GDK Glassware great power. For example, Android’s APIs for speech recognition, text-to-speech, hardware sensors, Bluetooth, media controller, location, and JNI and Java’s networking and threading features can all be used directly in your GDK Glassware. A word of caution, though: Some Android APIs running on Glass will return different results because Glass, as an Android-based device, has its own unique hardware support. All the details that can save you time will be covered in the later chapters. Here I’ll present a quick overview of the GDK APIs.
As described in the previous section, the timeline and timeline cards are the key elements of the Glass user experience. The following building blocks are what’s unique in the GDK and not available in the Mirror API:
By exposing the Glass API as an add-on to the Android API, the GDK no doubt has opened up limitless opportunities for developers to build innovative Glassware.
When to Use Which
This is similar to a question that arises when building mobile apps: Do you use the native APIs or the web-based solution? GDK allows you to access Glass’s hardware and develop advanced features available for offline use and with rich user interaction. But the learning curve is also steeper, especially if you don’t have Android development experience. The Mirror API uses Glass’s built-in functionality and can be developed with many common web development languages, but you need a web server running for the Mirror API, and there’s a courtesy limit of 1,000 requests per day per app for using the Mirror API.
If your app is mainly information-oriented and does not require an advanced user interface or if a server is required for content updates or data processing, then the Mirror API is more appropriate. If your app requires low-level hardware access or offline processing or rich user interaction or the user input data can be processed in the Glass itself, then the GDK is the right choice.
In some cases, you may want to build a hybrid app that uses both the Mirror API and the GDK. This is made possible because the static timeline card inserted by your Mirror API–based Glassware can invoke the GDK Glassware with a menu item associated with the card. I’ll show you a sample project that does this in Chapter 10.
You can also find a good summary on when to use each one at Glass’s developer site: https://developers.google.com/glass/develop/overview.
Understanding Google’s policies on Glass development can be important because as a developer, you need to know what you can and can’t do; you don’t want to spend lots of time developing an app such as facial recognition but find out later that it’s against Google’s policy. Here is a brief summary of the Google’s Glassware policies that are most likely related to your development effort:
There are a lot of other details in terms of Glassware policies. You should check Google Glass’s web site for any updates because the policies may be revised now and then.
Why This Book?
The goal of this book is to help developers jump-start the Glass development, no matter what their backgrounds are or whether they already own the Glass. I still remember in the first months of my learning iPhone programming, I was not aware of the book Beginning iPhone Development: Exploring the iPhone SDK, which is full of working code and step-by-step tutorials, so the learning curve with online documentation and samples with no clear tutorial-like explanations was pretty steep for me. When I first came across the book months later, I still remember my reaction: How I had wished I could have had the book the moment I started iPhone programming; it’d have saved me a lot of time.
The moral of the story is more than just “Be aware.” I’m trying to do the same thing in this book for those interested in Glass development: to help save a lot of your time and to provide you with lots of working code with clear explanations on every Glass development topic.
Who Is This Book For?
The book is mainly for mobile Android/iOS and web app developers, but other developers such as enterprise app developers can also easily follow the step-by-step tutorials and get up to speed quickly. However, I do assume you are familiar with some modern programming language.
In his book Social Psychology, David Myers, one of my favorite authors, stated, “I continue to envision this text as solidly scientific and warmly human, factually rigorous and intellectually provocative.” It may seem interesting that in this book for developers, I try to achieve the exact same goal. Glass is an amazing device built with solid and sophisticated technology; all the topics related to the Glass development need to be presented accurately and be “factually rigorous.” On the other hand, what really amazes me about Glass is that it can touch our human feelings by never missing a precious moment and by letting us feel Glassware is especially designed for us human. Check out the Glass design principles at https://developers.google.com/glass/design/principles and you’ll see how Glass and great Glassware can touch us at a deep level. I hope you’ll find that this book provides plenty of “intellectually provocative” samples and projects to inspire you.
For Beginning Android Developers
Most of this book requires you to be comfortable with Android, which is what the GDK and Glass are built upon. A good book to help you on that is Pro Android 4 by Satya Komatineni and Dave MacLean, published by Apress. The Android developer site also has great Training lessons (http://developer.android.com/training/index.html) that cover every major Android development topic.
Fully tested working sample code is included in step-by-step tutorials in each chapter for you to quickly learn every topic related to the GDK and the Mirror API.
For Intermediate or Advanced Android Developers
Advanced sample code with potential for real-world apps is also covered extensively in the book for you to apply as easily as possible to your own real projects.
If you are entering the Glassware development world as an iOS developer, you’ll be glad to find a unique treat in Chapter 7, Networking, Bluetooth and Social: I’ll show you how Glassware can be integrated with iOS apps to create more innovative apps.
If you want to use only the Mirror API to develop your Glassware, you can go to Chapter 10 directly. The code examples there are mainly in PHP and Java, but you should be able to easily understand them and port them to your familiar web programming language. It is true that even with just the Mirror API, you can develop practical and innovative Glassware (see the “What Kinds of Glassware Can You Develop?” section earlier in this chapter). After you become familiar with Java and Android, you can come back to learn how to develop GDK Glassware and hybrid apps.
If you don’t know how to program in Java (for the GDK or the Mirror API) or PHP (for the Mirror API), you should be able to learn the basics of it quickly online or from Apress books such as Learn Java for Android Development by Jeff Friesen or Beginning PHP and MySQL by Jason Gilmore. Before you do that, however, you may want to be strongly motivated by skimming through the book quickly to see what kind of Glassware you can develop and what it takes to build amazing Glassware.
For Nonprogrammers
Glass has been considered a paradigm-shifting mobile computing platform with great business potential. Naturally, if you’re a nontechnical entrepreneur with, for example, a design or business background, you’ll also want to know what is possible with Glass. You can take a quick look at the many examples in the book, get inspired, and be better prepared when teaming up with a developer to build your own Glass-based startup. If you want to test some cool GDK Glassware without having to let the developer physically access your Glass, you can also learn how to install all the apps developed in the book on your Glass.
Resources
Questions and Feedback
I always love to hear from readers. If you have any questions or feedback, please send me an e-mail at [email protected] or connect with me on Google+ with [email protected].
Summary
This chapter discussed several general topics about Glass and Glassware: Why Glass? What is Glass and Glassware? What can you do with GDK Glassware and Mirror Glassware? Why this book? Who is the book for? I hope by now you are eager to start the exciting Glass development journey ahead, no matter what your development background is. In Chapter 2, I’ll show you how to get your development environment set up and your first GDK Glassware up and running in no time.
3.147.76.135