Get Started

Twilio Class Reference

Overview

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

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

Nested Classes

Tasks

Name Description Type
initialize Initialize the Twilio Client SDK. Static method
shutdown Shuts down the Twilio Client SDK. Static method
isInitialized Determines if the Twilio Client SDK has been initialized or not. Static method
createDevice Create and initialize a new Device object. Static method
listDevices Retrieves a list of all active Devices. Static method

Methods

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.

Parameters
Name Description
inContext The 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.
inListener A InitListener that will notify you when the service is ready. Cannot be null.
Return Value

None


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

None


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.

Parameters
Name Description
inCapabilityToken A 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 www.twilio.com. The capabilities are used to begin listening for incoming connections and provide the default parameters used for establishing outgoing connections. Please visit http://www.twilio.com/docs/client/capability-tokens for more information.
inListener The 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