WearML

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
Command Description Child Elements

hf_override:
commands

  • Specifies 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:
commands
  • Specifies 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:
commands
  • Specifies 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_override
  • Specifies 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_overlay Disables the overlay. Yes
hf_overlay_number Specifies that a persistent numeric index should be displayed in the center of the element. No
hf_no_number Turn off numeric indexing and text overlays (i.e. SELECT ITEM X). Yes
hf_yes_number Turn on numeric indexing and text overlays. Yes
hf_overlay_offset Specifies 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_text Specifies that text overlays should be displayed. Yes
hf_persists Specifies that numeric indexing overlay or text overlay should always be displayed. Yes
hf_orientation:
option
Specifies the orientation of the text overlay relative to the numeric index overlay. See options. No
hf_show_dot Specifies that an overlay dot should be displayed to indicate a voice command. No
hf_show_icon Specifies that a microphone overlay icon should be displayed next to the text overlay to indicate a voice command. No
hf_background_color:
color
  • Specifies background color of the overlay.
  • The color should be specified as a hex value.
No
hf_text_color:
color
  • Specifies text color for the overlay.
  • The color should be specified as a hex value.
No
hf_use_text
  • Specify 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_description Specifies that the any none WearHF directive found in the content description should be used for the voice command. Yes
hf_hide_help Hides the “Show Help” icon. N/A
hf_text_normal
  • Characterizes 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_dictation Characterizes 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:
option
Characterizes 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_none Turn off head-tracked scrolling for the view. No
hf_scroll_horizontal
  • Specifies 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_vertical
  • Specifies 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_home
  • Turn 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_commands
  • Disables 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_results N/A
hf_make_clickable Force the view to be clicked with a mouse click when the speech command is spoken. No
hf_show_help_commands:
commands
  • Specifies 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
Option Description
qr Limit the barcode scanner to only scan QR type barcodes.
code128 Limit the barcode scanner to only scan Code 128 symbology barcodes.
upc Limit the barcode scanner to only scan Universal Product Code symbology barcodes.
ean Limit the barcode scanner to only scan EAN symbology barcodes.
any Allow the barcode scanner to scan any supported barcode types.

 

hf_orientation Options
Option Description
top Display text overlay on top of the numeric index overlay.
right Display text overlay to the right of the numeric index overlay.
bottom Display text overlay underneath the numeric index overlay.
left Display text overlay to the left of the numeric index overlay.