public class InteractiveVoiceViewAdapter extends Object implements InteractionListener, AudioPlaybackListener, MicrophoneListener, android.view.View.OnClickListener
InteractiveVoiceView view's
with the Amazon Lex client. It manages the client states and delivers results
through separate callbacks. This implementation of the adapter offers only
voice for voice out operations only.| Modifier and Type | Field and Description |
|---|---|
protected int |
state |
protected static int |
STATE_AUDIO_PLAYBACK |
protected static int |
STATE_AWAITING_RESPONSE |
protected static int |
STATE_LISTENING |
protected static int |
STATE_NOT_READY |
protected static int |
STATE_READY |
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancel()
Cancel current dialog.
|
protected void |
createInteractionClient()
Creates the interaction client, uses default interaction config setting
InteractionConfig
. |
String |
getAwsRegion()
Get the AWS regions set for this adapter.
|
static InteractiveVoiceViewAdapter |
getInstance(android.content.Context context,
InteractiveVoiceView micButton) |
void |
onAudioPlayBackCompleted()
Called after audio playback ends.
|
void |
onAudioPlaybackError(Exception e)
Called when audion playback fails.
|
void |
onAudioPlaybackStarted()
Called when audio playback has started.
|
void |
onClick(android.view.View v) |
void |
onInteractionError(Response response,
Exception e)
This method is invoked on error.
|
void |
onMicrophoneError(Exception e)
Indicates an error when recording sound on the microphone.
|
void |
onReadyForFulfillment(Response response)
This is invoked when all information required to fulfill a transaction
has been recovered.
|
void |
onRecordingEnd()
This is invoked when the client has stopped recording.
|
void |
onSoundLevelChanged(double soundLevel)
This is invoked to indicate a change in the sound level.
|
void |
promptUserToRespond(Response response,
LexServiceContinuation continuation)
This is invoked when input is required from the user.
|
void |
readyForRecording()
This is invoked when the client is ready for recording.
|
protected void |
reset()
Reset client.
|
void |
setAwsRegion(String awsRegion)
Set the AWS region where the Amazon Lex bot has been setup.
|
void |
setCredentialProvider(AWSCredentialsProvider credentialsProvider)
Set credentials provider.
|
void |
setInteractionConfig(InteractionConfig interactionConfig)
Set interaction config.
|
void |
setSessionAttributes(Map<String,String> sessionAttributes)
Set session attributes, these will be picked for the next dialog transaction.
|
protected void |
setVoiceListener(InteractiveVoiceView.InteractiveVoiceListener voiceListener)
Assign a listener for the voice interactions with the Amazon Lex bot.
|
void |
startedRecording()
This is invoked when the client has started recording.
|
protected void |
validateAppData()
Validates app details.
|
protected int state
protected static final int STATE_NOT_READY
protected static final int STATE_READY
protected static final int STATE_LISTENING
protected static final int STATE_AUDIO_PLAYBACK
protected static final int STATE_AWAITING_RESPONSE
public static InteractiveVoiceViewAdapter getInstance(android.content.Context context, InteractiveVoiceView micButton)
public void onAudioPlaybackStarted()
AudioPlaybackListeneronAudioPlaybackStarted in interface AudioPlaybackListenerpublic void onAudioPlayBackCompleted()
AudioPlaybackListeneronAudioPlayBackCompleted in interface AudioPlaybackListenerpublic void onAudioPlaybackError(Exception e)
AudioPlaybackListeneronAudioPlaybackError in interface AudioPlaybackListenere - Exception.public void onReadyForFulfillment(Response response)
InteractionListeneronReadyForFulfillment in interface InteractionListenerresponse - Response, contains the service
response.public void promptUserToRespond(Response response, LexServiceContinuation continuation)
InteractionListenerpromptUserToRespond in interface InteractionListenerresponse - Response, contains the service
response.continuation - LexServiceContinuation, allows to
continue with the current transaction.public void onInteractionError(Response response, Exception e)
InteractionListeneronInteractionError in interface InteractionListenerresponse - Response, contains the service
response.e - error reported as Exception.public void readyForRecording()
MicrophoneListenerreadyForRecording in interface MicrophoneListenerpublic void startedRecording()
MicrophoneListenerstartedRecording in interface MicrophoneListenerpublic void onRecordingEnd()
MicrophoneListeneronRecordingEnd in interface MicrophoneListenerpublic void onSoundLevelChanged(double soundLevel)
MicrophoneListeneronSoundLevelChanged in interface MicrophoneListenersoundLevel - Sound level as a Double.public void onMicrophoneError(Exception e)
MicrophoneListeneronMicrophoneError in interface MicrophoneListenere - Error as an Exception.public void onClick(android.view.View v)
onClick in interface android.view.View.OnClickListenerprotected void validateAppData()
Override this method to implement custom attribute verification.
protected void createInteractionClient()
InteractionConfig
.protected void cancel()
protected void reset()
protected void setVoiceListener(InteractiveVoiceView.InteractiveVoiceListener voiceListener)
voiceListener - public void setCredentialProvider(AWSCredentialsProvider credentialsProvider)
credentialsProvider - public void setInteractionConfig(InteractionConfig interactionConfig)
interactionConfig - The interaction config.public void setSessionAttributes(Map<String,String> sessionAttributes)
sessionAttributes - public void setAwsRegion(String awsRegion)
awsRegion - Copyright © 2018. All rights reserved.