Categories
Android

Launching a Delphi XE5 App via Voice on Google Glass

Building a running an app on Google Glass is easy with Delphi XE5, but what about integrating it into the Glass menu system and launching it with a voice command? Turns out that is pretty easy too.

First of all, I find it easiest to to add AndroidManifest.template.xml to your project. It shows up in your project folder after you build an Android app the first time. This template is for the AndroidManifest XML file that is used to describe your application to the Android OS. We open this file and find the element. We then need to add the following child to it, along with the and children elements already there.

<action android:name="com.google.android.glass.action.VOICE_TRIGGER">

This tells it that our main activity is eligible to receive the VOICE_TRIGGER intent. Next we need to specify which voice command we want to receive. This is done by adding a <meta-data> element outside of the <intent-filter> element (but still inside the <activity> element).

<meta-data android:name="com.google.android.glass.VoiceTrigger" android:resource="@xml/voice_trigger_start">

This specifies that there is VoiceTrigger metadata in the xml file voice_trigger_start.

Update: Thanks to the Glass XE16 KitKat update, a special permission is required to use a non standard voice trigger command. In the Manifest, right below the <%uses-permission%> line you need to add the following special
permission
:

<uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT">

So now we need to create that XML file. Simply right click on your project in the Project Manager and select Add New, then under Web Documents select XML File. Rename it to voice_trigger_start.xml, save it, and edit it to look like the following:

<!--?xml version="1.0" encoding="UTF-8"?-->
 <trigger keyword="My voice is my passport, verify me.">

The value of keyword can be any word or phrase that you want to associate with your app. This will be used in the sentence of “OK Glass, my voice is my passport, verify me.” Generally you want to keep it short, like “take a picture” or “get directions”, while not using something that conflicts with a built in command. This is also what will show up in the launcher on glass next to your app icon.

Now we use the Deployment Manager to specify the location for this new XML file. Simply go to Project \ Deployment and select Add File and choose the voice_trigger_start.xml file. Then change the Remote Path to res\xml.

Simply run your app from the IDE (after you’ve installed a Google Glass USB ADB driver) and after that you can launch your app from the Glass launcher or your selected voice command.

What to learn more about other devices and gadgets? Join me for my free webinar on Programming Devices and Gadgets with RAD Studio on January 22nd.Programming Devices and Gadgets with RAD Studio

5 replies on “Launching a Delphi XE5 App via Voice on Google Glass”

Comments are closed.