# VoiceInteractor.CommandRequest

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# CommandRequest

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/VoiceInteractor.CommandRequest "View this page in Java")  

```
class CommandRequest : VoiceInteractor.Request
```

|---|---|------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                              |||
| ↳ | [android.app.VoiceInteractor.Request](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request)                   ||
|   | ↳ | [android.app.VoiceInteractor.CommandRequest](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.CommandRequest#) |

Execute a vendor-specific command using the trusted system VoiceInteractionService. This allows an Activity to request additional information from the user needed to complete an action (e.g. booking a table might have several possible times that the user could select from or an app might need the user to agree to a terms of service). The result of the confirmation will be returned through an asynchronous call to either[onCommandResult(boolean,android.os.Bundle)](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.CommandRequest#onCommandResult(kotlin.Boolean,%20android.os.Bundle))or[onCancel()](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#onCancel()).

The command is a string that describes the generic operation to be performed. The command will determine how the properties in extras are interpreted and the set of available commands is expected to grow over time. An example might be "com.google.voice.commands.REQUEST_NUMBER_BAGS" to request the number of bags as part of airline check-in. (This is not an actual working example.)

## Summary

|                                                                                                                                                                                          Public constructors                                                                                                                                                                                           ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [CommandRequest](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.CommandRequest#CommandRequest(kotlin.String,%20android.os.Bundle))`(`command:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `args:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Create a new generic command request. |

|                                                                                                                                                                                                                                                     Public methods                                                                                                                                                                                                                                                      ||
|----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onCommandResult](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.CommandRequest#onCommandResult(kotlin.Boolean,%20android.os.Bundle))`(`isCompleted:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`, `result:` `[Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!`)` Results for CommandRequest can be returned in partial chunks. |

| Inherited functions ||
|---|---|
| From class[Request](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request) |------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)             | [cancel](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#cancel())`()` <br /> Cancel this active request. <br />                                                                                                                                                                                                                                                | | [Activity](https://developer.android.com/reference/kotlin/android/app/Activity)!         | [getActivity](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#getActivity())`()` <br /> Return the current[Activity](https://developer.android.com/reference/kotlin/android/app/Activity)this request is associated with. Will change if the activity is restarted such as through a configuration change. <br />                                               | | [Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)! | [getContext](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#getContext())`()` <br /> Return the current[Context](https://developer.android.com/reference/kotlin/android/content/Context.html#)this request is associated with. May change if the activity hosting it goes through a configuration change. <br />                                               | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!        | [getName](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#getName())`()` <br /> Return the name this request was submitted through[submitRequest(android.app.VoiceInteractor.Request,java.lang.String)](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor#submitRequest(android.app.VoiceInteractor.Request,%20kotlin.String)). <br /> | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)             | [onAttached](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#onAttached(android.app.Activity))`(`activity:` `[Activity](https://developer.android.com/reference/kotlin/android/app/Activity)!`)` <br /> The request is now attached to an activity, or being re-attached to a new activity after a configuration change. <br />                                 | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)             | [onCancel](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#onCancel())`()` <br /> Report from voice interaction service: this operation has been canceled, typically as a completion of a previous call to[cancel](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#cancel())or when the user explicitly cancelled. <br />    | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)             | [onDetached](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#onDetached())`()` <br /> The request is being detached from an activity. <br />                                                                                                                                                                                                                    | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)         | [toString](https://developer.android.com/reference/kotlin/android/app/VoiceInteractor.Request#toString())`()` <br />                                                                                                                                                                                                                                                                               | ||

## Public constructors

### CommandRequest

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
CommandRequest(
    command: String!, 
    args: Bundle!)
```

Create a new generic command request.

|                                                                       Parameters                                                                       ||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `command` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The desired command to perform.                           |
| `args`    | [Bundle](https://developer.android.com/reference/kotlin/android/os/Bundle.html#)!:Additional arguments to control execution of the command. |

## Public methods

### onCommandResult

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun onCommandResult(
    isCompleted: Boolean, 
    result: Bundle!
): Unit
```

Results for CommandRequest can be returned in partial chunks. The isCompleted is set to true iff all results have been returned, indicating the CommandRequest has completed.