WearML Embedded API

WearHF directives

The simplest way to optimize an application for the HMT is to use WearHF directives to tell WearHF how to interpret each screen in your application.

All WearHF directives are placed in a view’s content_description attribute. Multiple WearHF directives can be used in a single android:contentDescription line by separating the commands with a pipe character. For example:

android:contentDescription="hf_no_overlay|hf_no_ptt_home"

Content description

CommandDescriptionInherited by Child Elements?
hf_override:commandsSpecifies a number of voice commands for the screen, separated by pipes (|).

Only one instance of this directive should be used per screen.

Any default voice commands will be replaced by the commands provided.

When the user speaks a command it is passed back to your app via a broadcast intent. See the developer example for information on how to use this.

N/A
hf_commands:commandsSpecifies a number of voice commands for the element, separated by commas.

This will append the voice command to the existing voice commands that exist for the element.

When the user speaks one of the commands, the element will be clicked by WearHF.

N/A
hf_add_commands:commandsSpecifies a number of voice commands for the screen, separated by pipes (|). If the command starts with a hash symbol (#) the command will be assigned a numeric index (i.e. SELECT ITEM X…) too.

Only one instance of this directive should be used per screen.

Any default voice commands will be replaced by the commands provided.

When the user speaks a command it is passed back to your app via a broadcast intent. See the developer example for information on how to use this.

N/A
hf_wearml_overrideSpecifies a WearML script to use for view. The script must be converted to BASE64. Format is hf_wearml_override|BASE64_SCRIPT

Only one instance of this directive should be used per screen.

N/A
hf_no_overlayDisables the overlay.Yes
hf_overlay_numberSpecifies that a persistent numeric index should be displayed in the center of the element.No
hf_no_numberTurn off numeric indexing and text overlays (i.e. SELECT ITEM X…).Yes
hf_yes_numberTurn on numeric indexing and text overlays.Yes
hf_overlay_offsetSpecifies the offset for the voice command overlay. Format is hf_overlay_offset:x,y where x and y are integers specifying the offset in pixels.No
hf_show_textSpecifies that text overlays should be displayed.Yes
hf_persistsSpecifies that numeric indexing overlay or text overlay should always be displayed.Yes
hf_orientation:optionSpecifies the orientation of the text overlay relative to the numeric index overlay. See options.No
hf_show_dotSpecifies that an overlay dot should be displayed to indicate a voice command.No
hf_show_iconSpecifies that a microphone overlay icon should be displayed next to the text overlay to indicate a voice command.No
hf_background_color:colorSpecifies background color of the overlay.

The color should be specified as a hex value.

No
hf_text_color:colorSpecifies text color for the overlay.

The color should be specified as a hex value.

No
hf_use_textSpecify that an element should use the android:text field contents for its speech recognizer command. This is used to override the default behavior of auto selecting between the android:text and android:contentDescription fields. Normally android:contentDescription takes precedence over android:text.Yes
hf_use_descriptionSpecifies that the any none WearHF directive found in the contentDescription should be used for the voice command.Yes
hf_hide_helpHides the “Show Help” icon.N/A
hf_text_normalCharacterizes a text-field to tell WearHF present a virtual keyboard allowing the user to enter some text by selecting characters. This is the default behavior for text fields.No
hf_text_dictationCharacterizes a text-field to tell WearHF present a dictation keyboard allowing the user to enter some text by freely speaking text in sentences.No
hf_text_barcode:optionCharacterizes a text-field to tell WearHF present a barcode scanner allowing the user to enter some text by scanning a barcode. See options.No
hf_scroll_noneTurn off head-tracked scrolling for the view.No
hf_scroll_horizontalSpecifies that horizontal head-tracked scrolling should be turned on the the view, and the scrolling activity should be directed at the current UI element.

Only one instance of this directive should be used per screen.

N/A
hf_scroll_verticalSpecifies that vertical head-tracked scrolling should be turned on the this view, and the scrolling activity should be directed at the current UI element.

This is the default scroll setting if a scrollable element is discovered in the UI tree.

Only one instance of this directive should be used per screen.

N/A
hf_no_ptt_homeTurn off the default behavior for the current screen for the action button.

Under normal use pressing the action button will automatically switch to the Home Screen. However, this directive disables this behavior for the current screen, allowing an application to make full use of the action button itself.

The action button is used as a standard key press/release of key code = 500

Only one instance of this directive should be used per screen.

N/A
hf_no_global_commandsDisables the global commands (‘show help, navigate back, navigate home’, etc…)

Only one instance of this directive should be used per screen.

N/A
hf_broadcast_resultsTells WearHF to broadcast ASR results via a SPEECH_EVENT. See Development Example – Speech Recognizer for more details.

Only one instance of this directive should be used per screen.

N/A
hf_make_clickableForce the view to be clicked with a mouse click when the speech command is spoken.No
hf_show_help_commands:commandsSpecifies a number of voice commands to display in the show help window, separated by commas.

Only one instance of this directive should be used per screen.

N/A

hf_text_barcode Options

OptionDescription
qrLimit the barcode scanner to only scan QR type barcodes.
code128Limit the barcode scanner to only scan Code 128 symbology barcodes.
upcLimit the barcode scanner to only scan Universal Product Code symbology barcodes.
eanLimit the barcode scanner to only scan EAN symbology barcodes.
anyAllow the barcode scanner to scan any supported barcode types.

hf_orientation Options

OptionDescription
topDisplay text overlay on top of the numeric index overlay.
rightDisplay text overlay to the right of the numeric index overlay.
bottomDisplay text overlay underneath the numeric index overlay.
leftDisplay text overlay to the left of the numeric index overlay.