Stay organized with collections
Save and categorize content based on your preferences.
CommandRequest
class CommandRequest : VoiceInteractor.Request
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)
or 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 |
Create a new generic command request.
|
Public methods |
open Unit |
Results for CommandRequest can be returned in partial chunks.
|
Public constructors
CommandRequest
CommandRequest(
command: String!,
args: Bundle!)
Create a new generic command request.
Parameters |
command |
String!: The desired command to perform. |
args |
Bundle!: Additional arguments to control execution of the command. |
Public methods
onCommandResult
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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# VoiceInteractor.CommandRequest\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCommandRequest\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/VoiceInteractor.CommandRequest \"View this page in Java\") \n\n```\nclass CommandRequest : VoiceInteractor.Request\n```\n\n|---|---|-------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [android.app.VoiceInteractor.Request](/reference/kotlin/android/app/VoiceInteractor.Request) ||\n| | ↳ | [android.app.VoiceInteractor.CommandRequest](#) |\n\nExecute 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)](#onCommandResult(kotlin.Boolean,%20android.os.Bundle)) or [onCancel()](/reference/kotlin/android/app/VoiceInteractor.Request#onCancel()).\n\nThe 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.)\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [CommandRequest](#CommandRequest(kotlin.String,%20android.os.Bundle))`(`command:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `args:` `[Bundle](../os/Bundle.html#)!`)` Create a new generic command request. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onCommandResult](#onCommandResult(kotlin.Boolean,%20android.os.Bundle))`(`isCompleted:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`, `result:` `[Bundle](../os/Bundle.html#)!`)` Results for CommandRequest can be returned in partial chunks. |\n\n| Inherited functions ||\n|---|---|\n| From class [Request](/reference/kotlin/android/app/VoiceInteractor.Request) |-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [cancel](/reference/kotlin/android/app/VoiceInteractor.Request#cancel())`()` Cancel this active request. \u003cbr /\u003e | | [Activity](/reference/kotlin/android/app/Activity)! | [getActivity](/reference/kotlin/android/app/VoiceInteractor.Request#getActivity())`()` Return the current [Activity](/reference/kotlin/android/app/Activity) this request is associated with. Will change if the activity is restarted such as through a configuration change. \u003cbr /\u003e | | [Context](../content/Context.html#)! | [getContext](/reference/kotlin/android/app/VoiceInteractor.Request#getContext())`()` Return the current [Context](../content/Context.html#) this request is associated with. May change if the activity hosting it goes through a configuration change. \u003cbr /\u003e | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [getName](/reference/kotlin/android/app/VoiceInteractor.Request#getName())`()` Return the name this request was submitted through [submitRequest(android.app.VoiceInteractor.Request,java.lang.String)](/reference/kotlin/android/app/VoiceInteractor#submitRequest(android.app.VoiceInteractor.Request,%20kotlin.String)). \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onAttached](/reference/kotlin/android/app/VoiceInteractor.Request#onAttached(android.app.Activity))`(`activity:` `[Activity](/reference/kotlin/android/app/Activity)!`)` The request is now attached to an activity, or being re-attached to a new activity after a configuration change. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onCancel](/reference/kotlin/android/app/VoiceInteractor.Request#onCancel())`()` Report from voice interaction service: this operation has been canceled, typically as a completion of a previous call to [cancel](/reference/kotlin/android/app/VoiceInteractor.Request#cancel()) or when the user explicitly cancelled. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onDetached](/reference/kotlin/android/app/VoiceInteractor.Request#onDetached())`()` The request is being detached from an activity. \u003cbr /\u003e | | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [toString](/reference/kotlin/android/app/VoiceInteractor.Request#toString())`()` \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### CommandRequest\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nCommandRequest(\n command: String!, \n args: Bundle!)\n```\n\nCreate a new generic command request.\n\n| Parameters ||\n|-----------|--------------------------------------------------------------------------------------------------------------------|\n| `command` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The desired command to perform. |\n| `args` | [Bundle](../os/Bundle.html#)!: Additional arguments to control execution of the command. |\n\nPublic methods\n--------------\n\n### onCommandResult\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onCommandResult(\n isCompleted: Boolean, \n result: Bundle!\n): Unit\n```\n\nResults 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."]]