# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Nested Classes | Methods | Inherited Methods

# VoiceInteractor

`public final class VoiceInteractor`
`extends Object` ``

java.lang.Object
↳ | android.app.VoiceInteractor

Interface for an `Activity` to interact with the user through voice. Use `Activity.getVoiceInteractor` to retrieve the interface, if the activity is currently involved in a voice interaction.

The voice interactor revolves around submitting voice interaction requests to the back-end voice interaction service that is working with the user. These requests are submitted with `submitRequest(VoiceInteractor.Request)`, providing a new instance of a `Request` subclass describing the type of operation to perform -- currently the possible requests are `ConfirmationRequest` and `CommandRequest`.

Once a request is submitted, the voice system will process it and eventually deliver the result to the request object. The application can cancel a pending request at any time.

The VoiceInteractor is integrated with Activity's state saving mechanism, so that if an activity is being restarted with retained state, it will retain the current VoiceInteractor and any outstanding requests. Because of this, you should always use `Request#getActivity()` to get back to the activity of a request, rather than holding on to the activity instance yourself, either explicitly or implicitly through a non-static inner class.

## Summary

### Nested classes
`class` | `VoiceInteractor.AbortVoiceRequest` Reports that the current interaction can not be complete with voice, so the application will need to switch to a traditional input UI.
`class` | `VoiceInteractor.CommandRequest` Execute a vendor-specific command using the trusted system VoiceInteractionService.
`class` | `VoiceInteractor.CompleteVoiceRequest` Reports that the current interaction was successfully completed with voice, so the application can report the final status to the user.
`class` | `VoiceInteractor.ConfirmationRequest` Confirms an operation with the user via the trusted system VoiceInteractionService.
`class` | `VoiceInteractor.PickOptionRequest` Select a single option from multiple potential options with the user via the trusted system VoiceInteractionService.
`class` | `VoiceInteractor.Prompt` A set of voice prompts to use with the voice interaction system to confirm an action, select an option, or do similar operations.
`class` | `VoiceInteractor.Request` Base class for voice interaction requests that can be submitted to the interactor.

### Public methods
`VoiceInteractor.Request` | `getActiveRequest(String name)` Return any currently active request that was submitted with the given name.
`Request[]` | `getActiveRequests()` Return all currently active requests.
`boolean` | `isDestroyed()`
`void` | `notifyDirectActionsChanged()` Notifies the assist framework that the direct actions supported by the app changed.
`boolean` | `registerOnDestroyedCallback(Executor executor, Runnable callback)` Registers a callback to be called when the VoiceInteractor is destroyed.
`boolean` | `submitRequest(VoiceInteractor.Request request)`
`boolean` | `submitRequest(VoiceInteractor.Request request, String name)` Submit a new `Request` to the voice interaction service.
`boolean[]` | `supportsCommands(String[] commands)` Queries the supported commands available from the VoiceInteractionService.
`boolean` | `unregisterOnDestroyedCallback(Runnable callback)` Unregisters a previously registered onDestroy callback

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public methods

### getActiveRequest

    public VoiceInteractor.Request getActiveRequest (String name)

Return any currently active request that was submitted with the given name.

Parameters
`name` | `String`: The name used to submit the request, as per `submitRequest(android.app.VoiceInteractor.Request, java.lang.String)`.

Returns
`VoiceInteractor.Request` | Returns the active request with that name, or null if there was none.

### getActiveRequests

    public Request[] getActiveRequests ()

Return all currently active requests.

Returns
`Request[]` |

### isDestroyed

    public boolean isDestroyed ()

Returns
`boolean` | whether the voice interactor is destroyed. You should not interact with a destroyed voice interactor.

### notifyDirectActionsChanged

    public void notifyDirectActionsChanged ()

Notifies the assist framework that the direct actions supported by the app changed.

### registerOnDestroyedCallback

    public boolean registerOnDestroyedCallback (Executor executor,
                    Runnable callback)

Registers a callback to be called when the VoiceInteractor is destroyed.

Parameters
`executor` | `Executor`: Executor on which to run the callback. This value cannot be `null`. Callback and listener events are dispatched through this `Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `Context.getMainExecutor()`. To dispatch events through a shared thread pool, you can use `AsyncTask#THREAD_POOL_EXECUTOR`.
`callback` | `Runnable`: The callback to run. This value cannot be `null`.

Returns
`boolean` | whether the callback was registered.

### submitRequest

    public boolean submitRequest (VoiceInteractor.Request request)

Parameters
`request` | `VoiceInteractor.Request`

Returns
`boolean` |

### submitRequest

    public boolean submitRequest (VoiceInteractor.Request request,
                    String name)

Submit a new `Request` to the voice interaction service. The request must be one of the available subclasses -- `ConfirmationRequest`, `PickOptionRequest`, `CompleteVoiceRequest`, `AbortVoiceRequest`, or `CommandRequest`.

Parameters
`request` | `VoiceInteractor.Request`: The desired request to submit.
`name` | `String`: An optional name for this request, or null. This can be used later with `getActiveRequests()` and `getActiveRequest(String)` to find the request.

Returns
`boolean` | Returns true of the request was successfully submitted, else false.

### supportsCommands

    public boolean[] supportsCommands (String[] commands)

Queries the supported commands available from the VoiceInteractionService. The command is a string that describes the generic operation to be performed. An example might be "org.example.commands.PICK_DATE" to ask the user to pick a date. (Note: This is not an actual working example.)

Parameters
`commands` | `String`: The array of commands to query for support.

Returns
`boolean[]` | Array of booleans indicating whether each command is supported or not.

### unregisterOnDestroyedCallback

    public boolean unregisterOnDestroyedCallback (Runnable callback)

Unregisters a previously registered onDestroy callback

Parameters
`callback` | `Runnable`: The callback to remove. This value cannot be `null`.

Returns
`boolean` | whether the callback was unregistered.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*