Class CallInvite
- All Implemented Interfaces:
android.os.Parcelable
accept(Context, Call.Listener)
or
reject(Context)
-
Nested Class Summary
-
Field Summary
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Method Summary
Modifier and TypeMethodDescriptionaccept
(android.content.Context context, AcceptOptions acceptOptions, Call.Listener listener) accept
(android.content.Context context, Call.Listener listener) int
boolean
Returns theCallerInfo
that provides caller verification information about the caller.Returns the CallSid.Returns the custom parameters.getFrom()
Returns the caller information when available.getTo()
Returns the callee information.static boolean
isValid
(android.content.Context context, android.os.Bundle data) Validates whether the payload is a valid notification sent by Twilio.static boolean
Validates whether the payload is a valid notification sent by Twilio.void
reject
(android.content.Context context) Rejects the incomingCallInvite
.sendMessage
(CallMessage message) Sends a user-defined message to endpoints that have subscribed for user-defined messages.void
writeToParcel
(android.os.Parcel dest, int flags)
-
Field Details
-
CREATOR
public static final android.os.Parcelable.Creator CREATOR
-
-
Method Details
-
getFrom
Returns the caller information when available. -
getTo
Returns the callee information. -
getCallSid
Returns the CallSid. -
getCallerInfo
Returns theCallerInfo
that provides caller verification information about the caller. -
getCustomParameters
Returns the custom parameters.// Pass custom parameters in TwiML <?xml version="1.0" encoding="UTF-8"?> <Response> <Dial answerOnBridge="false" callerId="client:alice"> <Client> <Identity>bob</Identity> <Parameter name="caller_first_name" value="alice" /> <Parameter name="caller_last_name" value="smith" /> </Client> </Dial> </Response>
`callInvite.getCustomParameters()` returns a map of key-value pair passed in the TwiML."caller_first_name" -> "alice" "caller_last_name" -> "smith"
-
accept
@NonNull public Call accept(@NonNull android.content.Context context, @NonNull AcceptOptions acceptOptions, @NonNull Call.Listener listener) Accepts theCallInvite
with the providedAcceptOptions
and returns a newCall
. ASecurityException
will be thrown if RECORD_AUDIO is not granted.Call.Listener
receives the state of theCall
.Call.Listener events Callback Name Description Since version Call.Listener.onConnectFailure(Call, CallException)
The call failed to connect. CallException
provides details of the root cause.3.0.0-preview1 Call.Listener.onRinging(Call)
This callback should not be invoked when calling accept(Context, AcceptOptions, Call.Listener)
3.0.0-preview2 Call.Listener.onConnected(Call)
The call has connected. 3.0.0-preview1 Call.Listener.onDisconnected(Call, CallException)
The call was disconnected. If the call ends due to an error the CallException
is non-null. If the call ends normallyCallException
is null.3.0.0-preview1 If
accept
fails,Call.Listener.onConnectFailure(Call, CallException)
callback is raised withCallException
.VoiceException.getMessage()
andVoiceException.getExplanation()
provide details of the failure. IfCall.disconnect()
is called while attempting to accept, theCall.Listener.onDisconnected(Call, CallException)
callback will be raised with no error.If
accept(Context, AcceptOptions, Call.Listener)
fails due to an authentication error, the SDK receives the following error.Authentication Exceptions Authentication Exception Error Code Description VoiceException.EXCEPTION_AUTH_FAILURE
20151 Twilio failed to authenticate the client If
accept(Context, AcceptOptions, Call.Listener)
fails due to any other reason, the SDK receives one of the following errors.Insights :
Insights events Group Name Event Name Description Since version connection accepted-by-local Call state remains Call.State.CONNECTING
3.0.0-beta2 settings codec Negotiated selected codec is received and remote SDP is set 5.0.1 If accept fails, an error event is published to Insights.
Insights events Group Name Event Name Description Since version connection error Error description. Call state transitions to Call.State.DISCONNECTED
3.0.0-beta2 - Parameters:
context
- An Android context.acceptOptions
- The options that configure the accepted call.listener
- A listener that receives call status.- Returns:
- A new
Call
- Usage example:
IceOptions iceOptions = new IceOptions.Builder() .iceTransportPolicy(IceTransportPolicy.RELAY) .build(); AcceptOptions acceptOptions = new AcceptOptions.Builder() .iceOptions(iceOptions) .build(); Call call = callInvite.accept(context, acceptOptions, new Call.Listener() { @Override public void onRinging(@NonNull Call call) { // This callback will not be invoked when accepting a call invite } @Override public void onConnected(@NonNull final Call call) { Log.d(TAG, "Received onConnected " + call.getSid()); } @Override public void onConnectFailure(@NonNull Call call, @NonNull CallException callException) { Log.d(TAG, "Received onConnectFailure with CallException: " + callException.getErrorCode()+ ":" + callException.getMessage()); } @Override public void onDisconnected(@NonNull Call call, CallException callException) { if (callException != null) { Log.d(TAG, "Received onDisconnected with CallException: " + callException.getMessage() + ": " + call.getSid()); } else { Log.d(TAG, "Received onDisconnected"); } } }); }
-
accept
@NonNull public Call accept(@NonNull android.content.Context context, @NonNull Call.Listener listener) Accepts theCallInvite
with defaultAcceptOptions
and returns a newCall
. ASecurityException
will be thrown if RECORD_AUDIO is not granted.Call.Listener
receives the state of theCall
.Call.Listener events Callback Name Description Since version Call.Listener.onConnectFailure(Call, CallException)
The call failed to connect. CallException
provides details of the root cause.3.0.0-preview1 Call.Listener.onRinging(Call)
This callback should not be invoked when calling accept(Context, Call.Listener)
3.0.0-preview2 Call.Listener.onConnected(Call)
The call has connected. 3.0.0-preview1 Call.Listener.onDisconnected(Call, CallException)
The call was disconnected. If the call ends due to an error the CallException
is non-null. If the call ends normallyCallException
is null.3.0.0-preview1 If
accept
fails,Call.Listener.onConnectFailure(Call, CallException)
callback is raised withCallException
.VoiceException.getMessage()
andVoiceException.getExplanation()
provide details of the failure. IfCall.disconnect()
is called while attempting to accept, theCall.Listener.onDisconnected(Call, CallException)
callback will be raised with no error.If
accept(Context, Call.Listener)
fails due to an authentication error, the SDK receives the following error.Authentication Exceptions Authentication Exception Error Code Description VoiceException.EXCEPTION_AUTH_FAILURE
20151 Twilio failed to authenticate the client If
accept(Context, Call.Listener)
fails due to any other reason, the SDK receives one of the following errors.Insights :
Insights events Group Name Event Name Description Since version connection accepted-by-local Call state remains Call.State.CONNECTING
3.0.0-beta2 settings codec Negotiated selected codec is received and remote SDP is set 5.0.1 If accept fails, an error event is published to Insights.
Insights events Group Name Event Name Description Since version connection error Error description. Call state transitions to Call.State.DISCONNECTED
3.0.0-beta2 - Parameters:
context
- An Android context.listener
- A listener that receives call status.- Returns:
- A new
Call
- Usage example:
Call call = callInvite.accept(context, new Call.Listener() { @Override public void onRinging(@NonNull Call call) { // This callback will not be invoked when accepting a call invite } @Override public void onConnected(@NonNull final Call call) { Log.d(TAG, "Received onConnected " + call.getSid()); } @Override public void onConnectFailure(@NonNull Call call, @NonNull CallException callException) { Log.d(TAG, "Received onConnectFailure with CallException: " + callException.getErrorCode()+ ":" + callException.getMessage()); } @Override public void onDisconnected(@NonNull Call call, CallException callException) { if (callException != null) { Log.d(TAG, "Received onDisconnected with CallException: " + callException.getMessage() + ": " + call.getSid()); } else { Log.d(TAG, "Received onDisconnected"); } } }); }
-
reject
public void reject(@NonNull android.content.Context context) Rejects the incomingCallInvite
.Insights :
Insights events Group Name Event Name Description Since version connection rejected-by-local Call invite is rejected 3.0.0-beta2 connection error The event will be sent with code 31600 and message "Busy Everywhere : SIP/2.0 600 Call Rejected" 3.1.0 -
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags) - Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
-
sendMessage
Sends a user-defined message to endpoints that have subscribed for user-defined messages. The result will be raised to theCall.CallMessageListener
provided as either a callback argument to theVoice.handleMessage(Context, Map, MessageListener)
method and/or as an accept option when a call invite is either accepted or rejected. Calling the `sendMessage` method without subscribing first will result in an error in your Twilio developer console. Sending a call message with content size that exceeds 10 KB or sending more than 10 call messages within one minute will result in theCall.CallMessageListener.onMessageFailure(String, String, VoiceException)
callback. When attempting to send a message larger than 10k, the error will not show in the developer console.- Parameters:
message
- The call message to send.- Returns:
- An unique identifier for tracking the message.
-
isValid
public static boolean isValid(android.content.Context context, android.os.Bundle data) Validates whether the payload is a valid notification sent by Twilio. A valid notification payload will result in aCallInvite
being raised viaMessageListener.onCallInvite(CallInvite)
callback when passed toVoice.handleMessage(...)
.- Parameters:
context
- An Android context.data
- Push notification payload.- Returns:
- A boolean value that indicates whether the payload is a valid notification sent by Twilio.
-
isValid
Validates whether the payload is a valid notification sent by Twilio. A valid notification payload will result in aCallInvite
being raised viaMessageListener.onCallInvite(CallInvite)
callback when passed toVoice.handleMessage(...)
.- Parameters:
context
- An Android context.data
- Push notification payload.- Returns:
- A boolean value that indicates whether the payload is a valid notification sent by Twilio.
-
equals
-