What is an immersion?
An immersion is basically an Android activity. The name immersion implies that it is not part of the normal Glass timeline. Instead it takes full control of the device - except for the back gesture (Swipe down). To go back to the timeline you need to leave the immersion.
|Once started an immersion takes full control of the screen.|
Create a normal Android project with the following settings:
- Set minSdkVersion and targetSdkVersion to 15 (Android 4.0.3)
- Set compileSdkVersion to "Google Inc.:Glass Development Kit Sneak Peek:15"
- Do not assign a theme to your application or derive your own theme from Theme.DeviceDefault
Let's create a simple activity. The Card class helps us to create a layout that looks like a timeline card.
Launching the Glassware - Voice commands
After creating the activity we need a way to start our Glassware. A common way to launch Glassware is to use a voice trigger. Let's add a simple voice trigger to start our hello world activity.
First we need to declare a string resource for our voice command.
The next step is to create an XML resource file for the voice trigger using the previously created string value.
Now we can add an intent filter for the VOICE_TRIGGER action to our activity. A meta-data tag links it to the XML file we wrote above.
The developer guide requires you to add an icon for the touch menu to the activity (white in color on transparent background, 50x50 pixels). The Glass Asset Studio is a helpful tool to generate these icons.
The final Glassware
Now we can start our Glassware by saying "ok glass, show hello world":
Another option to start our Glassware is to use the touch menu and scroll to the "show hello world" command:
The source code for this Hello World Glassware is available on GitHub.