Android SDK

The Plivo Android SDK lets you integrate voice into your Android apps.

Download the Alpha

Examples using the SDK

Basic Calling Stuff

Register an endpoint

public final static String PLIVO_USERNAME = "Tatooine";
  public final static String PLIVO_PASSWORD = "Jabba";
  Endpoint endpoint = Endpoint.newInstance(true, this);
  endpoint.login(PLIVO_USERNAME, PLIVO_PASSWORD);

Make an outbound call

public final static String PHONE_NUMBER = "1415XXXXXXX";
  outgoing = endpoint.createOutgoingCall();
  outgoing.call(PHONE_NUMBER);

Receive a call

Implement EventListener on your class and override the onIncomingCall method.

public void onIncomingCall(Incoming incoming) {
      incoming.answer();
}

Endpoint Class

Endpoint class allows you to register a Plivo SIP Endpoint. Once an endpoint is registered, calls can be made or received using the same.

public boolean login(String username, String password)

This method is used to register an endpoint. If the endpoint is successfully registered a notification would be sent to the onLogin method of the EventListener. In case of a failure a notification is sent to the onLoginFailed method of the EventListener.

@param

username - The username of the endpoint created on Plivo

password - The password of the endpoint created on Plivo

public boolean logout()

This method is used to unregister an endpoint.

@param

None

public Outgoing createOutgoingCall ()

Calling this method would return an Outgoing object, linked to the registered endpoint. Calling this method on an unregistered PlivoEndpoint object would return null.

@param

None

@returns

Outgoing object which can be used to make outbound calls

public void resetEndpoint ()

Calling this method would reset the Endpoint object. This method is used to re-register an endpoint when the application goes in and out of network connectivity.

@param

None

Outgoing Class

Outgoing class contains methods to make and control an outbound call.

public boolean call(String dest)

A method to make an outbound call.

  • @param dest A SIP URI or a number to make a call to.
public boolean mute()

Calling this method on the Outgoing object would mute the call.

@param

None

public boolean unmute()

Calling this method on the Outgoing object would unmute the call.

@param

None

public boolean sendDigits(String digit)

Calling this method on the Outgoing object with the digits would send DTMF on that call.

@param

digit-The digits to be sent as a String

public void hangup()

Calling this method on the Outgoing object would hangup the call.

@param

None

Incoming

Incoming class contains methods to handle an incoming call. An object of this class will be received on the public void onIncomingCall(Incoming incoming) eventListener.

public void answer()

This method is used to answer an incoming call.

@param

None

public boolean mute()

This method is used to mute the call.

@param

None

public boolean unmute()

This method is used to unmute the call. Calling this method on an already unmuted call won't have any effect.

@param

None

public boolean sendDigits(String digit)

Calling this method on the Incoming object with the digits would send DTMF on that call.

  • @param digit The digits to be sent as a String
public void hangup()

Calling this method on the Incoming object would disconnect the call.

@param

None

public void reject()

Calling this method would reject the incoming call.

@param

None

EventListener methods

public void onLogin()

This method gets called when registration to an endpoint is successful.

public void onLoginFailed()

This method gets called when registration to an endpoint fails.

public void onIncomingCall(Incoming incoming)

On an incoming call to a registered endpoint, this method receives a Incoming object.

public void onIncomingCallRejected(Incoming incoming)

On an incoming call, if the call is rejected by the caller, this method would be triggered with the Incoming object.

public void onIncomingCallHangup(Incoming incoming)

On an incoming call, if the call is disconnected by the caller after being answered, this method would be triggered with the Incoming object.

public void onIncomingDigitNotification(String digit)

On an active endpoint, this delegate would be called with the digit received on the call.

public void onOutgoingCall(Outgoing outgoing)

When an outgoing call is ringing, this delegate would be called with the Outgoing object.

public void onOutgoingCallAnswered(Outgoing outgoing) 

When an outgoing call is answered, this method would be called with the Outgoing object.

public void onOutgoingCallHangup(Outgoing outgoing);

When an outgoing call is disconnected by the called number after the call has been answered, this method would be triggered with the Outgoing object.

public void onOutgoingCallRejected(Outgoing outgoing);

When an outgoing call is rejected by the called number, this method would be triggered with the Outgoing object.

public void onOutgoingCallInvalid(Outgoing outgoing);

When an outgoing call is made to an invalid number, this method would be triggered with the Outgoing object.