java.lang.Object | |
↳ | android.service.voice.VoiceInteractionSession |
An active voice interaction session, providing a facility for the implementation
to interact with the user in the voice interaction layer. This interface is no shown
by default, but you can request that it be shown with showWindow()
, which
will result in a later call to onCreateContentView()
in which the UI can be
built
A voice interaction session can be self-contained, ultimately calling finish()
when done. It can also initiate voice interactions with applications by calling
startVoiceActivity(Intent)
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
VoiceInteractionSession.Caller | |||||||||||
VoiceInteractionSession.Insets | Information about where interesting parts of the input method UI appear. | ||||||||||
VoiceInteractionSession.Request |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Finish the session.
| |||||||||||
Convenience for inflating views.
| |||||||||||
Retrieve the window being used to show the session's UI.
| |||||||||||
Request to abort the voice interaction session because the voice activity can not
complete its interaction using voice.
| |||||||||||
Called when the
VoiceInteractor has asked to cancel a VoiceInteractionSession.Request
that was previously delivered to onConfirm(VoiceInteractionSession.Caller, VoiceInteractionSession.Request, CharSequence, Bundle) or onCommand(VoiceInteractionSession.Caller, VoiceInteractionSession.Request, String, Bundle) . | |||||||||||
Sessions automatically watch for requests that all system UI be closed (such as when
the user presses HOME), which will appear here.
| |||||||||||
Process an arbitrary extended command from the caller,
corresponding to a
VoiceInteractor.CommandRequest . | |||||||||||
Compute the interesting insets into your UI.
| |||||||||||
Request to confirm with the user before proceeding with an unrecoverable operation,
corresponding to a
VoiceInteractor.ConfirmationRequest . | |||||||||||
Initiatize a new session.
| |||||||||||
Hook in which to create the session's UI.
| |||||||||||
Last callback to the session as it is being finished.
| |||||||||||
Request to query for what extended commands the session supports.
| |||||||||||
Called when a key down event has occurred.
| |||||||||||
Called when a long press has occurred.
| |||||||||||
Called when multiple down/up pairs of the same key have occurred
in a row.
| |||||||||||
Called when a key up event has occurred.
| |||||||||||
Called when the last activity of a task initiated by
startVoiceActivity(android.content.Intent) has finished. | |||||||||||
Called when a task initiated by
startVoiceActivity(android.content.Intent)
has actually started. | |||||||||||
You can call this to customize the theme used by your IME's window.
| |||||||||||
Ask that a new activity be started for voice interaction.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
android.view.KeyEvent.Callback
|
Finish the session.
Request to abort the voice interaction session because the voice activity can not
complete its interaction using voice. Corresponds to
VoiceInteractor.AbortVoiceRequest
. The default implementation just sends an empty
confirmation back to allow the activity to exit.
caller | Who is making the request. |
---|---|
request | The active request. |
message | The message informing the user of the problem, as per
VoiceInteractor.AbortVoiceRequest . |
extras | Any additional information, as per
VoiceInteractor.AbortVoiceRequest .
|
Called when the VoiceInteractor
has asked to cancel a VoiceInteractionSession.Request
that was previously delivered to onConfirm(VoiceInteractionSession.Caller, VoiceInteractionSession.Request, CharSequence, Bundle)
or onCommand(VoiceInteractionSession.Caller, VoiceInteractionSession.Request, String, Bundle)
.
request | The request that is being canceled. |
---|
Sessions automatically watch for requests that all system UI be closed (such as when
the user presses HOME), which will appear here. The default implementation always
calls finish()
.
Process an arbitrary extended command from the caller,
corresponding to a VoiceInteractor.CommandRequest
.
caller | Who is making the request. |
---|---|
request | The active request. |
command | The command that is being executed, as per
VoiceInteractor.CommandRequest . |
extras | Any additional information, as per
VoiceInteractor.CommandRequest .
|
Compute the interesting insets into your UI. The default implementation
uses the entire window frame as the insets. The default touchable
insets are TOUCHABLE_INSETS_FRAME
.
outInsets | Fill in with the current UI insets. |
---|
Request to confirm with the user before proceeding with an unrecoverable operation,
corresponding to a VoiceInteractor.ConfirmationRequest
.
caller | Who is making the request. |
---|---|
request | The active request. |
prompt | The prompt informing the user of what will happen, as per
VoiceInteractor.ConfirmationRequest . |
extras | Any additional information, as per
VoiceInteractor.ConfirmationRequest .
|
Initiatize a new session.
args | The arguments that were supplied to
VoiceInteractionService.startSession .
|
---|
Last callback to the session as it is being finished.
Request to query for what extended commands the session supports.
caller | Who is making the request. |
---|---|
commands | An array of commands that are being queried. |
Called when a key down event has occurred. If you return true,
you can first call KeyEvent.startTracking()
to have the framework track the event
through its onKeyUp(int, KeyEvent)
and also call your
onKeyLongPress(int, KeyEvent)
if it occurs.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Called when a long press has occurred. If you return true,
the final key up will have FLAG_CANCELED
and
FLAG_CANCELED_LONG_PRESS
set. Note that in
order to receive this callback, someone in the event change
must return true from onKeyDown(int, KeyEvent)
and
call startTracking()
on the event.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Called when multiple down/up pairs of the same key have occurred in a row.
keyCode | The value in event.getKeyCode(). |
---|---|
count | Number of pairs as returned by event.getRepeatCount(). |
event | Description of the key event. |
Called when a key up event has occurred.
keyCode | The value in event.getKeyCode(). |
---|---|
event | Description of the key event. |
Called when the last activity of a task initiated by
startVoiceActivity(android.content.Intent)
has finished. The default
implementation calls finish()
on the assumption that this represents
the completion of a voice action. You can override the implementation if you would
like a different behavior.
intent | The original Intent supplied to
startVoiceActivity(android.content.Intent) . |
---|---|
taskId | Unique ID of the finished task. |
Called when a task initiated by startVoiceActivity(android.content.Intent)
has actually started.
intent | The original Intent supplied to
startVoiceActivity(android.content.Intent) . |
---|---|
taskId | Unique ID of the now running task. |
You can call this to customize the theme used by your IME's window.
This must be set before onCreate(Bundle)
, so you
will typically call it in your constructor with the resource ID
of your custom theme.
Ask that a new activity be started for voice interaction. This will create a
new dedicated task in the activity manager for this voice interaction session;
this means that Intent.FLAG_ACTIVITY_NEW_TASK
will be set for you to make it a new task.
The newly started activity will be displayed to the user in a special way, as a layer under the voice interaction UI.
As the voice activity runs, it can retrieve a VoiceInteractor
through which it can perform voice interactions through your session. These requests
for voice interactions will appear as callbacks on onGetSupportedCommands(VoiceInteractionSession.Caller, String[])
,
onConfirm(VoiceInteractionSession.Caller, VoiceInteractionSession.Request, CharSequence, Bundle)
, onCommand(VoiceInteractionSession.Caller, VoiceInteractionSession.Request, String, Bundle)
, and onCancel(VoiceInteractionSession.Request)
.
You will receive a call to onTaskStarted(Intent, int)
when the task starts up
and onTaskFinished(Intent, int)
when the last activity has finished.
intent | The Intent to start this voice interaction. The given Intent will
always have Intent.CATEGORY_VOICE added to it, since
this is part of a voice interaction.
|
---|