Google Glass Development

Google Glass Development Without Glass

Here are the slides of my “Google Glass Development without Glass” presentation. As I promised, here is the follow-up blogpost with some code samples. If you haven’t seen my presentation, I strongly suggest clicking through the slides!


Technologies emerge. Extremely. Wearable trend takes over the world. It seems like every week we start with articles about brand new devices, which would change our life! We’ve heard about lots of glasses, watches, wristbands, you name it. The most popular one is definitely Google Glass. Actually, it is Glass, who started this wearable hype!
You can just imagine, how all the wearbles can impact our daily and extreme activities.

From the other point of view, each new device brings new UX, SDKs and APIs. That’s why we, developers, have to quickly adopt to the new techs. In this sense, Google Glass is a rather good device for developers. It runs the world-known Android OS. It just has an extremely strange UI and UX.

Google created a set of “best practices” of awesome Glassware. Actually, it can be applied to any wearble software:

  • Design for device — know & test your device and it’s abilities.
  • Don’t get in the way — show the best data when users want it and be out of the way when they don’t.
  • Keep it timely — platform is the most effective when in-the-moment and up-to-date.
  • Avoid the unexpected — surprising users with unexpected functionality is bad. On any platform.

Glass is different from the regular phone or tablet. The usual way of creating Android apps is through the Android SDK. Because of specific Glass’s usage principles, Google introduced Mirror API. We’ll dive into both of them later in the post.

1. Obtaining Glass

If you are among those 10000 , who have Glass, you can skip this chapter. Unfortunately, that’s just 0.000002% of the world’s population. So, welcome Stranger to this amazing world of Glass hacking without Glass.
nexus glass

Hopefully, you have some Android device. Then, you can install Google Glass UI there (disclaimer: I’ve tried this with Nexus 7 tablet with 4.2.2 rom and it worked perfectly, but I can’t guarantee it will work on other device). In short, Google Glass UI is just another Home screen provider for your Android. In order to set it up, follow these steps:

  1. Go to:
  2. Download Glass APKs:
  3. Install them as you usually install APKs from third-parties
  4. Follow steps at to set up your “Nexus Glass”
  5. Say “ok glass, take a picture” and share your “woohoo-reaction” with the world #throughglass
You’ve obtained Glass. Now its time to hack!
Let’s dive into Glass development with the help of our friend Mr. Bond. James Bond.
Once upon a time, he was in London. Somehow, he’s got his Google Glass and enjoys the experience on a daily basis.

2. Example #1: Mirror API

If you are eager to try Mirror API out and don’t want to mess with quick-start projects, I have a shortcut for you!
Let’s try inserting a simple card into Glass Timeline:

  1. Go to: Google API Explorer –> Mirror API –> mirror.timeline.insert
  2. Authorise via OAuth 2.0. Use Glass scopes:
  3. Populate request fields with values from the API.
  4. Execute request!
  5. Here’s a link with some pre-populated data.

Now it’s time to have even more fun! Let’s try setting up demo-project.

  1. Set up a new project in
  2. Go to API Access, update project settings:
    1. Add to Redirect URIs:
      • http://localhost:8080/oauth2callback
    2. Add to JavaScript origins:
        • http://localhost:8080
        • (will be useful later)
  3. Clone
  4. Update file src/main/resources/ with the values provided in Google API Access Console.
  5. mvn jetty:run it.

If everything goes smooth, you’ll be able to authorize and have fun with your Glass Timeline! If you want to have even more fun with Mirror API, especially with Subscriptions to Location and Notifications, you should deploy your war to the real webserver. Google sends these updates only to https secured web-sites. For development purposes you can use provided ssl-proxy. Just modify MirrorClient#insertSubscription method.

3. Example #2: GDK

Update: Google recently released GDK Sneak Peak. Right now, when you try creating apps with it and running it on Nexus Glass, you’ll get [INSTALL_FAILED_MISSING_SHARED_LIBRARY]. We’re trying to find the way, to avoid that. As of now, there’s no support for the official GDK Sneak Peak (auth, live cards, etc).

Google Glass is just another Android device with 640×360 screen (hello, screen fragmentation), Android 4.0.4, API level 15. Maybe, in the next releases of Glass, this will change. Now, when you want to port your existing Android app to Google Glass, you should just:

  1. Build your APK.
  2. Install it.
  3. Run via adb.
  4. Understand, that you need to update touch gestures support.
  5. Understand, that your UI is hardly usable.
  6. Understand, that your awesome Google Maps stopped working.
  7. So, double-check your application on real device! Everything can change in the near future!

It’s a good idea to check out Google Glass Quick Start by Google. It explains a lot about Timeline, UI, Gestures and current limitations of the GDK.

In order to support touch gestures of Google Glass, have a look at this article: Touch Gestures. In short, here’s the table with events corresponding to keycodes:

Swipe right KEYCODE_TAB
Swipe left KEYCODE_TAB + isShiftPressed()

4. Example #3: GDK + Timeline API

Update: Google released GDKvXE12 update. It has Static Card support, but it is still limited and lacks menus, html templates, etc. The code mentioned below follows hacky way and may not work on the latest version of Glass.

So far, we’ve tried the official Mirror API way and the hacky GDK road. Now its time to combine both approaches. Let’s insert a card into Timeline from withing your app!

I’ve  set up a sample project at github for you: After you fork/clone it, you can see glasslib.jar inside libs folder. This library would probably become the aforementioned GDK. It provides everything you need to know about Timeline UI.

All the magic is done via these steps:

  1. Initialise Timeline, get Timeline contentresolver. Look at:, int, int).
  2. Create MenuItems for your card.
  3. Create TimelineItem.
  4. Insert it into ContentResolver.
Look through the classes & methods provided inside glasslib.jar. I hope, you’ll find loads of interesting information!

5. Outro

Thanks everyone, for reading all the way down here. I hope now you have your pseudo-Glass and know how to develop for it. Share your experience in the comments and on github! Ok guys, have fun #throughglass!

sun set

sun set