Twilio Class Reference


  • Package: com.twilio.client
  • Subclass of: Object

Abstract class used to initialize and shut down the Twilio Client SDK.

Nested Classes


initializeInitialize the Twilio Client SDK.Static method
shutdownShuts down the Twilio Client SDK.Static method
isInitializedDetermines if the Twilio Client SDK has been initialized or not.Static method
createDeviceCreate and initialize a new Device object.Static method
listDevicesRetrieves a list of all active Devices.Static method


void initialize(Context inContext, InitListener inListener)

Initialize the Twilio Client SDK.

The SDK needs to start an Android Service to handle voice. When this service has been started, a Device can be created and used.

inContextThe Application Context from your Android app. Make sure you don't pass an Activity Context. You can retrieve the Application Context by calling getApplicationContext() on your Activity. Cannot be null.
inListenerA InitListener that will notify you when the service is ready. Cannot be null.
Return Value


void shutdown()

Shuts down the Twilio Client SDK.

This will terminate all connections, release all Device objects, and release any resources used by the SDK.

Note that any attempt to access existing Device or Connection objects after calling this method may cause an exception to be thrown, or a crash.

Return Value


boolean isInitialized()

Determines if the Twilio Client SDK has been initialized or not.

If you expect your application to run in the background when the user has switched to other applications, you will want to check the return value of this method on startup. The Android OS may have killed your application due to memory pressure, but the SDK may still be running in the background.

Return Value

true if the SDK is currently initialized, false otherwise

Device createDevice(String inCapabilityToken, DeviceListener inListener)

Create and initialize a new Device object.

If the incoming capabilities are defined, then the device will automatically begin listening for incoming connections.

inCapabilityTokenA signed JSON Web Token that defines the features available to the Device. These may be created using the Twilio Helper Libraries included with the SDK or available at The capabilities are used to begin listening for incoming connections and provide the default parameters used for establishing outgoing connections. Please visit for more information.
inListenerThe optional listener object which will receive events from a Device object.
Return Value

The initialized Device object, or null if the SDK was not initialized

List<> listDevices()

Retrieves a list of all active Devices.

Return Value

An unmodifiable List of Device objects

public static void setLogLevel(int level)

Sets the logging level for messages logged by the Twilio SDK.

Log levels correspond to those specified by Android's Log class.

To disable all Twilio SDK logging, set this to Log.ASSERT. The default is Log.ERROR.

public static void setMetrics(boolean enable)

Toggle the call quality analytics publishing feature of the Twilio SDK. This is enabled by default.