public class NexmoCall
extends java.lang.Object
NexmoCall class is a NexmoConversation for phone calls. Class represents a calls to a user (IP) or phone
number (PSTN).
Note: Instance is created by
NexmoClient.call(String, NexmoCallHandler, NexmoRequestListener), or received from NexmoIncomingCallListener.onIncomingCall(NexmoCall).
Before making a call NexmoClient has to be initialized.
Make a call:
client.call("username/phone number", NexmoCallHandler.IN_APP/NexmoCallHandler.SERVER, new NexmoRequestListener<NexmoCall>() {
@Override
public void onSuccess(NexmoCall call) {
Log.d("onSuccess", "Call started: " + call.toString());
}
@Override
public void onError(NexmoAPIError error) {
Log.d("onError", "Error: Unable to start a call " + apiError.getMessage());
}
);
To answer the call use answer(NexmoRequestListener) method:
call.answer(new NexmoRequestListener() { @Override public void onSuccess(@Nullable NexmoCall nexmoCall) { Log.d("onSuccess", "Call answered"); } @Override public void onError(@NonNull NexmoApiError apiError) { Log.d("onError", "Error answering call"); } });
To end existing call or reject incoming call call use NexmoCall#hangup(NexmoRequestListener) method:
call.hangup(new NexmoRequestListener() { @Override public void onSuccess(@Nullable NexmoCall nexmoCall) { Log.d("onSuccess", "Call hanged up"); } @Override public void onError(@NonNull NexmoApiError apiError) { Log.d("onError", "Error hanging up the call"); } });
For more use cases and samples please check the client-sdk-android-samples repository.
| Modifier and Type | Method and Description |
|---|---|
void |
addCallEventListener(NexmoCallEventListener callEventListener)
Adds a callback to be invoked when call related event occurs.
|
void |
answer(NexmoRequestListener<NexmoCall> listener)
Answers the incoming
NexmoCall and joins the conversation that you are invited to. |
java.util.List<NexmoMember> |
getAllMembers()
Gets the list of all
NexmoMember participants in the call. |
NexmoConversation |
getConversation()
Gets the
NexmoConversation of the call object. |
NexmoCallMemberStatus |
getMemberCallStatus(NexmoMember member) |
NexmoMember |
getMyMember()
Gets the current user's
NexmoMember . |
void |
hangup(NexmoRequestListener<NexmoCall> listener)
Hangups or rejects the call.
|
void |
mute(boolean isMuted)
Mutes/unmutes current user in this call.
|
void |
reconnect()
Manually Reconnect media Stream
|
void |
removeCallEventListener(NexmoCallEventListener callEventListener)
Removes
NexmoCallEventListener instance listener from the current call. |
void |
sendDTMF(java.lang.String dtmf,
NexmoRequestListener<java.lang.Void> listener)
Sends DTMF digits to the call.
|
public java.util.List<NexmoMember> getAllMembers()
NexmoMember participants in the call.NexmoMember.public NexmoMember getMyMember()
NexmoMember .NexmoMember.public NexmoConversation getConversation()
NexmoConversation of the call object.NexmoConversation;.public void answer(NexmoRequestListener<NexmoCall> listener)
NexmoCall and joins the conversation that you are invited to.listener - The request completion listener. NexmoRequestListener.onSuccess(Object) returns the current NexmoCall object.public void hangup(NexmoRequestListener<NexmoCall> listener)
listener - The request completion listener. NexmoRequestListener.onSuccess(Object) returns the current NexmoCall object.public void reconnect()
public void mute(boolean isMuted)
isMuted - Mute or un-mute.public void sendDTMF(java.lang.String dtmf,
NexmoRequestListener<java.lang.Void> listener)
dtmf - The DTMF digit(s) to sendlistener - The request completion listener.public void addCallEventListener(NexmoCallEventListener callEventListener)
callEventListener - implementation NexmoCallEventListener.public NexmoCallMemberStatus getMemberCallStatus(NexmoMember member)
member - conversation member.public void removeCallEventListener(NexmoCallEventListener callEventListener)
NexmoCallEventListener instance listener from the current call.callEventListener - implementation NexmoCallEventListener.