public class AlexaManager
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
checkLoggedIn(AsyncCallback<java.lang.Boolean,java.lang.Throwable> callback)
Check if the user is logged in to the Amazon service, uses an async callback with a boolean to return response
|
static AlexaManager |
getInstance(Context context,
java.lang.String productId) |
SpeechSendAudio |
getSpeechSendAudio() |
SpeechSendText |
getSpeechSendText() |
SpeechSendVoice |
getSpeechSendVoice() |
VoiceHelper |
getVoiceHelper() |
boolean |
isRecording()
Helper function to check if we're currently recording
|
void |
logIn(AuthorizationCallback callback)
Send a log in request to the Amazon Authentication Manager
|
void |
sendAudioRequest(byte[] data,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send raw audio data to the Alexa servers, this is a more advanced option to bypass other issues (like only one item being able to use the mic at a time).
|
void |
sendAudioRequest(DataRequestBody requestBody,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send streamed raw audio data to the Alexa servers, this is a more advanced option to bypass other issues (like only one item being able to use the mic at a time).
|
void |
sendAudioRequest(int requestType,
byte[] data,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Deprecated.
|
void |
sendExpectSpeechTimeoutEvent(AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send confirmation that the device has timed out without receiving a speech request when expected
|
void |
sendMutedEvent(boolean isMute,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send a confirmation to the Alexa server that the mute state has been changed in response to a directive
|
void |
sendOpenDownchannelDirective(AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send a get
Directive request to the Alexa server to open a persistent connection |
void |
sendSynchronizeStateEvent(AsyncCallback<AvsResponse,java.lang.Exception> callback)
|
void |
sendTextRequest(int requestType,
java.lang.String text,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Deprecated.
|
void |
sendTextRequest(java.lang.String text,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send a text string request to the AVS server, this is run through Text-To-Speech to create the raw audio file needed by the AVS server.
|
void |
sendVolumeChangedEvent(long volume,
boolean isMute,
AsyncCallback<AvsResponse,java.lang.Exception> callback)
Send a confirmation to the Alexa server that the device volume has been changed in response to a directive
|
void |
startRecording(AsyncCallback<java.lang.Void,java.lang.Exception> callback)
Deprecated.
|
void |
startRecording(byte[] assetFile,
AsyncCallback<java.lang.Void,java.lang.Exception> callback)
Deprecated.
- Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and
stopRecording(AsyncCallback) ,
use sendAudioRequest(byte[], AsyncCallback) and manage state within your Application/Activity. |
void |
startRecording(int requestType,
AsyncCallback<java.lang.Void,java.lang.Exception> callback)
Deprecated.
|
void |
startRecording(int requestType,
byte[] assetFile,
AsyncCallback<java.lang.Void,java.lang.Exception> callback)
Deprecated.
|
void |
startRecording(int requestType,
java.lang.String assetFile,
AsyncCallback<java.lang.Void,java.lang.Exception> callback)
Deprecated.
|
void |
startRecording(java.lang.String assetFile,
AsyncCallback<java.lang.Void,java.lang.Exception> callback)
Deprecated.
|
void |
stopRecording(AsyncCallback<AvsResponse,java.lang.Exception> callback)
Deprecated.
- Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and
startRecording(AsyncCallback) (AsyncCallback)},
use sendAudioRequest(byte[], AsyncCallback) and manage state within your Application/Activity. |
public static AlexaManager getInstance(Context context, java.lang.String productId)
public SpeechSendVoice getSpeechSendVoice()
public SpeechSendText getSpeechSendText()
public SpeechSendAudio getSpeechSendAudio()
public VoiceHelper getVoiceHelper()
public void checkLoggedIn(@NotNull AsyncCallback<java.lang.Boolean,java.lang.Throwable> callback)
callback
- state callbackpublic void logIn(@Nullable AuthorizationCallback callback)
callback
- state callbackpublic void sendOpenDownchannelDirective(@Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
Directive
request to the Alexa server to open a persistent connectioncallback
- state callbackpublic void sendSynchronizeStateEvent(@Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
callback
- state callbackpublic boolean isRecording()
@Deprecated public void startRecording(int requestType, @Nullable AsyncCallback<java.lang.Void,java.lang.Exception> callback) throws java.io.IOException
startRecording(int, byte[], AsyncCallback)
* @deprecated - Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and stopRecording(AsyncCallback)
,
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.java.io.IOException
@Deprecated public void startRecording(@Nullable AsyncCallback<java.lang.Void,java.lang.Exception> callback)
startRecording(int, byte[], AsyncCallback)
* @deprecated - Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and stopRecording(AsyncCallback)
,
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.@Deprecated public void startRecording(int requestType, @Nullable java.lang.String assetFile, @Nullable AsyncCallback<java.lang.Void,java.lang.Exception> callback) throws java.io.IOException
startRecording(int, byte[], AsyncCallback)
* @deprecated - Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and stopRecording(AsyncCallback)
,
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.java.io.IOException
@Deprecated public void startRecording(@Nullable java.lang.String assetFile, @Nullable AsyncCallback<java.lang.Void,java.lang.Exception> callback) throws java.io.IOException
startRecording(int, byte[], AsyncCallback)
* @deprecated - Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and stopRecording(AsyncCallback)
,
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.java.io.IOException
@Deprecated public void startRecording(int requestType, @Nullable byte[] assetFile, @Nullable AsyncCallback<java.lang.Void,java.lang.Exception> callback)
startRecording(int, byte[], AsyncCallback)
* @deprecated - Deprecated because of the difficulty of managing Application state in an external library. Avoid using this and stopRecording(AsyncCallback)
,
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.@Deprecated public void startRecording(@Nullable byte[] assetFile, @Nullable AsyncCallback<java.lang.Void,java.lang.Exception> callback)
stopRecording(AsyncCallback)
,
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.stopRecording(AsyncCallback)
--these need to be triggered manually or programmatically as a pair.
This operation is done off the main thread and may need to be brought back to the main thread on callbacks.
Check to see if the user is logged in, and if not, we request login, when they log in, or if they already are, we start recording audio
to pass to the Amazon AVS server. This audio can be pre-pended by the byte[] assetFile, which needs to match the audio requirements of
the rest of the service.assetFile
- our nullable byte[] that prepends audio to the record requestcallback
- our state callback@Deprecated public void stopRecording(@Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
startRecording(AsyncCallback)
(AsyncCallback)},
use sendAudioRequest(byte[], AsyncCallback)
and manage state within your Application/Activity.callback
- @Deprecated public void sendTextRequest(int requestType, java.lang.String text, @Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
public void sendTextRequest(java.lang.String text, @Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
text
- the arbitrary text that we want to send to the AVS servercallback
- the state change callback@Deprecated public void sendAudioRequest(int requestType, byte[] data, AsyncCallback<AvsResponse,java.lang.Exception> callback)
public void sendAudioRequest(byte[] data, @Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
data
- the audio data that we want to send to the AVS servercallback
- the state change callbackpublic void sendAudioRequest(DataRequestBody requestBody, @Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
requestBody
- a request body that incorporates either a static byte[] write to the BufferedSink or a streamed, managed byte[] data sourcecallback
- the state change callbackpublic void sendVolumeChangedEvent(long volume, boolean isMute, @Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
volume
- volume as reported by the AvsAdjustVolumeItem
DirectiveisMute
- report whether the device is currently mutedcallback
- state callbackpublic void sendMutedEvent(boolean isMute, @Nullable AsyncCallback<AvsResponse,java.lang.Exception> callback)
isMute
- mute state as reported by the AvsSetMuteItem
Directivecallback
- public void sendExpectSpeechTimeoutEvent(AsyncCallback<AvsResponse,java.lang.Exception> callback)
callback
-