Stay organized with collections
Save and categorize content based on your preferences.
ConfirmationRequest
class ConfirmationRequest : VoiceInteractor.Request
Confirms an operation with the user via the trusted system VoiceInteractionService. This allows an Activity to complete an unsafe operation that would require the user to touch the screen when voice interaction mode is not enabled. The result of the confirmation will be returned through an asynchronous call to either onConfirmationResult(boolean,android.os.Bundle)
or onCancel()
- these methods should be overridden to define the application specific behavior.
In some cases this may be a simple yes / no confirmation or the confirmation could include context information about how the action will be completed (e.g. booking a cab might include details about how long until the cab arrives) so the user can give a confirmation.
Summary
Public constructors |
Create a new confirmation request.
|
Public methods |
open Unit |
Handle the confirmation result.
|
Public constructors
ConfirmationRequest
ConfirmationRequest(
prompt: VoiceInteractor.Prompt?,
extras: Bundle?)
Create a new confirmation request.
Parameters |
prompt |
VoiceInteractor.Prompt?: Optional confirmation to speak to the user or null if nothing should be spoken. |
extras |
Bundle?: Additional optional information or null. |
Public methods
onConfirmationResult
open fun onConfirmationResult(
confirmed: Boolean,
result: Bundle!
): Unit
Handle the confirmation result. Override this method to define the behavior when the user confirms or rejects the operation.
Parameters |
confirmed |
Boolean: Whether the user confirmed or rejected the operation. |
result |
Bundle!: Additional result information or null. |
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.ConfirmationRequest\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nConfirmationRequest\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/VoiceInteractor.ConfirmationRequest \"View this page in Java\") \n\n```\nclass ConfirmationRequest : 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.ConfirmationRequest](#) |\n\nConfirms an operation with the user via the trusted system VoiceInteractionService. This allows an Activity to complete an unsafe operation that would require the user to touch the screen when voice interaction mode is not enabled. The result of the confirmation will be returned through an asynchronous call to either [onConfirmationResult(boolean,android.os.Bundle)](#onConfirmationResult(kotlin.Boolean,%20android.os.Bundle)) or [onCancel()](/reference/kotlin/android/app/VoiceInteractor.Request#onCancel()) - these methods should be overridden to define the application specific behavior.\n\nIn some cases this may be a simple yes / no confirmation or the confirmation could include context information about how the action will be completed (e.g. booking a cab might include details about how long until the cab arrives) so the user can give a confirmation.\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [ConfirmationRequest](#ConfirmationRequest(android.app.VoiceInteractor.Prompt,%20android.os.Bundle))`(`prompt:` `[VoiceInteractor.Prompt](/reference/kotlin/android/app/VoiceInteractor.Prompt)?`, `extras:` `[Bundle](../os/Bundle.html#)?`)` Create a new confirmation request. |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onConfirmationResult](#onConfirmationResult(kotlin.Boolean,%20android.os.Bundle))`(`confirmed:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`, `result:` `[Bundle](../os/Bundle.html#)!`)` Handle the confirmation result. |\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### ConfirmationRequest\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nConfirmationRequest(\n prompt: VoiceInteractor.Prompt?, \n extras: Bundle?)\n```\n\nCreate a new confirmation request.\n\n| Parameters ||\n|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `prompt` | [VoiceInteractor.Prompt](/reference/kotlin/android/app/VoiceInteractor.Prompt)?: Optional confirmation to speak to the user or null if nothing should be spoken. |\n| `extras` | [Bundle](../os/Bundle.html#)?: Additional optional information or null. |\n\nPublic methods\n--------------\n\n### onConfirmationResult\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onConfirmationResult(\n confirmed: Boolean, \n result: Bundle!\n): Unit\n```\n\nHandle the confirmation result. Override this method to define the behavior when the user confirms or rejects the operation.\n\n| Parameters ||\n|-------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `confirmed` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): Whether the user confirmed or rejected the operation. |\n| `result` | [Bundle](../os/Bundle.html#)!: Additional result information or null. |"]]