Dec 16, 2013

Mirror API and GDK - Developing for Google Glass #1

I recently got my hands on Google Glass and decided to write some articles about developing applications for Glass. After all it's Android that is running on Glass.

What is Glass?
It's very complicated to explain Google Glass just using text. Only wearing and using it will give you this aha moment. However the following video, made by Google, gives you a good impression about how it feels like.


What is Glass from a developer's point of view?
Google Glass is an Android device running Android 4.0.3. What you see through Glass is basically a customized Launcher / Home screen application (a timeline of cards about current and past events) and a slightly different theme. This makes it really interesting for Android developers to develop for Glass: You can use almost all the familiar Android framework APIs. However wearing Glass feels totally different than using a mobile phone. So there's a big difference in designing applications. But not only the UI is different: You can't just port an existing application to Glass. Use cases have to be designed especially for Glass. Some features of your app might not make sense on Glass. Some other interesting features might only be possible on Glass. It's almost impossible to get a feeling for that without using Glass for some days.

Back to writing code.. Currently we can decide between two ways to develop for Glass: The Mirror API or an early preview of the Glass Development Kit (GDK). Let's have a look at both and see what they are capable of.

The Mirror API
The Mirror API has been the first API that has been introduced by the Glass team. It's a server-side API meaning the applications don't run on Glass itself but on your server and it's your server that interacts with Glass.

The Mirror API is great for pushing cards to the timeline of Glass and sharing content from Glass with your server application.

Some examples of applications that could use the Mirror API:
  • Twitter client: The server pushes interesting tweets to the timeline of the Glass owner. The user can share photos and messages with the application and they will be posted to the Twitter timeline.
  • Context-aware notifications: Your server subscribes to the user's location. Every now and then your server will receive the latest user location. You use this location to post interesting and related cards to the timeline of the user.

More about the Mirror API:
With the GDK you can build Android applications that run directly on Glass. Think of the GDK as Android 4.0.3 SDK with some extra APIs for Google Glass. It's worth mentioning that the GDK is currently in an early preview state. The API is not complete and some important parts are missing.

When developing Glass you have two options how your application should show up on Glass:

Live Cards

How a live card shows up in the Glass timeline.

Your application shows up as a card in the timeline (left of the Glass clock). You have again two options how to render these cards:
  • Low-Frequency Rendering: Your card is rendered using Remote Views. Think of it as a Home screen widget on Android phones. A background service is responsible for updating these views. You only update the views every now and then.
  • High Frequency Rendering: Your background service renders directly on the live card's surface. You can draw anything and are not limited to Android views. Furthermore you can update the card many times a second.
Immersion

An Immersion is not part of the timeline but "replaces" it.


An immersion is at the bottom a regular Android activity. For your activity to look like a timeline card:
  • Don't assign a theme to your activity or use the DeviceDefault theme as base for your customization.
  • Even though you can use the touch pad of Glass almost like a d-pad: Try to avoid most input-related Android widgets. They don't make much sense on Glass because you are not using a touch screen. Instead try to use gestures with the GestureDetector class or voice input.
  • Use the Card class and its toView() method to create a view that looks like regular Glass card.

More about the GDK

No comments:

Post a Comment