Share via


Define the set of speech-enabled text controls (Android)

Dynamically changing text controls in activities

If you dynamically change the set of views in an activity (for example, your app adds/removes, enables/disables or hides/shows specific text fields depending on the user’s actions), you must synchronize the VUI form to recognize these changes.

To do this, call the synchronize method on the activity’s VuiController; the VUI bundle available to the user is adjusted.

Important

If you create an entire activity dynamically (instead of using an XML declaration), you must also create the VuiController instance as the root view with its VuiController(Context) constructor. Only views that you add as children to the VuiController instance will be speech-enabled.

Excluding text controls from speech recognition

Prerequisites

You've created and speech-enabled an activity.

Procedure

If an activity in your app displays GUI text controls that you want to exclude from speech recognition, do the following:

  1. Obtain a reference to the VuiController object in your activity and the EditText View.

  2. Call the following method on the VuiController object: void enableView(View view, boolean enabled).

    For example: theVuiController.enableView(example_txt, false);

    • theVuiController - the reference to the VUI controller object in your activity.

    • example_txt - the reference to the EditText View.

  3. Call synchronize() on the VuiController to apply the changes.

Note

If you set text controls to be disabled or hidden, these won't be speech-enabled by default. Password field text controls aren't speech-enabled by default.

Speech-enabling hidden/disabled text controls

Prerequisites

  • You've created and speech-enabled an activity.

  • You've set text controls to be disabled or added password fields; these aren't speech-enabled by default.

Procedure

If an activity in your app displays GUI text controls that are disabled or password fields, and you want to speech-enable those GUI text controls, do the following:

  1. Obtain a reference to the VuiController object in your activity and the EditText View.

  2. Call the following method on the VuiController object: void enableView(View view, boolean enabled)

    For example: theVuiController.enableView(example_txt, true);

    • theVuiController - the reference to the VUI controller object in your activity.

    • example_txt - the reference to the EditText View.

  3. Call synchronize() on the VuiController to apply the changes.

The text control is now speech-enabled. This means that users of your app can record into this text control and the GUI control can be reached via voice navigation.

Note

Speech recognition isn't possible in hidden text controls, even if they're explicitly enabled via the void enableView(View view, boolean enabled) method.