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 (http://creativecommons.org/licenses/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 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:
- 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.
- 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.
- 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 Mainservlet.java file.
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);
This is similar to the Android application that uses the Camera Intent.
Include the code snippet below in your MainServlet.java file to invoke GDK code.
MenuItem item = new MenuItem();
setPayload function contains the path to the MainActivity.java 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.