Android SDK Reference

The Plivo Android SDK allows you to create applications capable of making and receiving calls in your Android app. This SDK support both IPv4 and IPv6 Networks, that means you can make and receive calls when your device is connected to a network that uses IPv4, IPv6, or both versions of the protocol. The SDK currently supports Android version 6 and above.

This document gives an overview of different classes and methods available in Plivo Android SDK V2.0.0

New in Android SDK v2.0.0

Incoming call support through firebase push notifications

SDK is provided in both .aar file format

Android SDK support starting from Android 6.0 until latest Android 9

New Example application which covers all the SDK features.

Initialization of application

Registering an endpoint

Declare or use user input for the sip uri endpoint and password from Plivo Console.

Following are the methods available in Endpoint class:

Method: login(String username, String password, String fcmToken)

Description:

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

Method: login(String username, String password, int regTimeout)

Description:

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

Note: This login method has a limitation - Incoming call may not work if the app goes to background.

username - The username of the endpoint created on Plivo.

password - The password of the endpoint created on Plivo.

regTimeout - Seconds to re register if the app is in foreground. Default value is 600 seconds. Value range is from 120 sec to 86400.

Usage:

Method: logout

public boolean logout()

Description:

This method is used to unregister an endpoint.

Usage:

endpoint.logout();

Method: createOutgoingCall

public Outgoing createOutgoingCall ()

Description:

Calling this method returns an Outgoing object linked to the registered endpoint. It returns an Outgoing object which can be used to make outbound calls.
Calling this method on an unregistered PlivoEndpoint object returns null.
To add custom headers during an outgoing call, use the extraHeaders.put function

Method: onIncomingDigitNotification

public void onIncomingDigitNotification(String digits)

Description:

On an active endpoint, this delegate will be called with the digit received on the call.
Note: “*” and “#” are received as “-6” and “-13” respectively on the SDK. App need to explicitly convert these on this callback onIncomingDigitNotification(String digits).

Best Practice: is to not use the deprecated methods, because these will be prone to crashes NoMethodError when removed in future.

Best Practice: Use the deviceToken while logging in to get the incoming call as push notification, instead of using the background service to run forever in the background and observe for incoming calls.

BestPractice: Always use endpoint.resetEndpoint() while logout, so that all the allocated memory resources will be deleted on the SDK.