Click here to Skip to main content
14,267,350 members

Building Applications for Google Glass

Rate this:
0.00 (No votes)
Please Sign up or sign in to vote.
0.00 (No votes)
7 Apr 2015CPOL
This article discusses design considerations for building apps for Glass and how to build hybrid glass applications using the Mirror API and GDK.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Intel® Developer Zone offers tools and how-to information for cross-platform app development, platform and technology information, code samples, and peer expertise to help developers innovate and succeed. Join our communities for Android, Internet of Things, Intel® RealSense™ Technology, and Windows to download tools, access dev kits, share ideas with like-minded developers, and participate in hackathon’s, contests, roadshows, and local events.

Glass* wearable computing devices from Google (Figure 1) are head-mounted optical displays. Manufactured by Foxconn and built by Google, Glass runs Android* 4.4x with a dual-core SoC.

Figure 1. By Danlev (Own work) [CC BY-SA 3.0 (], via Wikimedia Commons

This article discusses design considerations for building apps for Glass and how to build hybrid glass applications using the Mirror API and GDK.

Design Considerations

Design fact: Glass has a timeline-like interface that is displayed on the screen. Sliding backwards shows active events like weather and sliding forward shows calls received, photos taken, etc.

It is estimated that an average user would spend less than 4 seconds looking at the Glass screen. This presents some interesting design challenges and opportunities.

It is recommended that applications be:

  1. Contextual: Contextual applications give information relevant to the user’s environment and don’t require more than a few seconds of the user’s attention. For example, a user can check to see when a particular flight is arriving before heading to the airport to pick up a friend.
    Design: Live card
    Live cards appear in the present section of the timeline and display current information.
  2. Quick updates: Applications like news stories should only contain headlines and appear as quick updates instead of complete stories. It is also recommended that developers provide the read-aloud option so users can listen to the complete story.
    Design: Static card
    Static cards appear in the past section of the timeline and can be reviewed by users at their convenience.
  3. Don’t design apps that require a lot of user input. Most information should be available with a single swipe. Include some action buttons and keep them simple and voice-controllable.

Building Hybrid Glass applications

Glass applications are generally categorized as two types:

Mirror API helps you build web-based services that interact with Glass. Most of the code is run on the cloud and not on Glass itself. Google has provided Mirror API starter projects to help developers explore different APIs and outputs before writing actual code.

Glass Development Kit (GDK) is an add-on to the Android SDK that helps you build apps that run directly on Glass. GDK helps access sensors like the accelerometer and GPS that are available on Glass as well as hardware features like the camera.

Hybrid Glass applications are those that use both Mirror API and GDK. The application for our code walk-through is a hybrid one.

Walk-through of the Code Example

This application is designed to help STEM instructors and students engage in an effective educational experience. This glassware app uses Mirror API to receive laboratory experiment instructions provided by the teachers and post the steps on the students’ Google Glass devices. The students then follow the steps to perform their lab sessions. Every instruction has a picture of what the result of that step should look like and helps the student verify that they are doing the experiment right. There is also a read-aloud option to read out instructions to students. At the end of the experiment the student can submit the end result by taking a picture and sending it to the instructor.

Google provides Mirror API quick-start projects in Java*, Python*, and PHP*. In this example, we use the Java quick-start project, which creates all the necessary files required to invoke the Mirror API. Add your logic to the file.

Hybrid application

This application combines the use of the camera and Mirror API. Students use the camera to take a picture of the end product. Since Mirror API cannot access device capabilities, we use GDK to create a Java program to handle capturing an image. Let’s call this package Chembuddy and place it in the same package as the Mirror API project.


Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);

This is similar to the Android application that uses the Camera Intent.

Include the code snippet below in your file to invoke GDK code.

//Communicating with GDK to invoke the native camera

MenuItem item = new MenuItem();

The setPayload function contains the path to the file, which is responsible for invoking the camera.

Setting Read Aloud option

Create a menu item on the card and set its action to READ_ALOUD.

MenuItem item = new MenuItem();

Point to the text on your card that you would like to read aloud using a string variable speakabletext.

speakabletext = el.getElementsByTag("p").first().text();

Set this value to the timelineItem


Follow the GitHub link in the references section for the complete source code.


Glass opens up exciting opportunities for application developers to build context-sensitive apps that benefit users. Focus as much on the app’s design as on its development. It is important to keep in mind the general guidelines for designing an application for a wearable device.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Android on Intel
United States United States
Intel is inside more and more Android devices, and we have tools and resources to make your app development faster and easier.

Comments and Discussions

-- There are no messages in this forum --
Posted 7 Apr 2015


4 bookmarked