Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

ConnectionListener Interface Reference

Deprecation Notice

The Twilio Client SDK for Android has been deprecated and replaced by Twilio's new Programmable Voice SDK.

The Programmable Voice SDK offers many improvements over the Twilio Client SDK, including greater stability, improved backgrounding, and built-in support for push notifications for incoming calls.

If you're just getting started with a Twilio mobile application for voice calling, we recommend you use the Programmable Voice SDK. If you're already using the Twilio Client SDK, you should plan to upgrade to the Programmable Voice SDK as soon as you're able.

Get started with the new Programmable Voice SDK by checking out the quickstart for Programmable Voice SDK for Android on Github.

Overview

  • Package: com.twilio.client

The ConnectionListener interface defines a set of callbacks for events related to a Connection.

Tasks

Name Description Type
onConnecting Called for a newly-created Connection when it is connecting to your Twilio application. Instance method
onConnected Called after the Connection has successfully connected to your Twilio application. Instance method
onDisconnected Called after the Connection has been disconnected, ignored, or rejected by either party. Instance method
onDisconnected Called when an error occurs on the specified connection. Instance method

Methods

void onConnecting(Connection inConnection)

Called for a newly-created Connection when it is connecting to your Twilio application.

When this occurs, Connection is in the State state.

Parameters
Name Description
inConnection The Connection that has started connecting
Return Value

None


void onConnected(Connection inConnection)

Called after the Connection has successfully connected to your Twilio application.

Note that this does not necessarily mean your application has executed successfully; it only indicates that the connection has been established.

When this occurs the Connection will be in the State state.

Parameters
Name Description
inConnection The Connection that has finished connecting
Return Value

None


void onDisconnected(Connection inConnection)

Called after the Connection has been disconnected, ignored, or rejected by either party.

When this occurs the Connection will be in the State state.

Parameters
Name Description
inConnection The Connection that has disconnected
Return Value

None


void onDisconnected(Connection inConnection, int inErrorCode, String inErrorMessage)

Called when an error occurs on the specified connection.

After this callback has been called, it is safe to assume that the connection is no longer connected.

When this occurs the Connection will be in the State state.

For a list of error codes and their meanings, see http://www.twilio.com/docs/client/errors.

Parameters
Name Description
inConnection The Connection that has experienced an error
inErrorCode The error code that pinpoints the error
inErrorMessage A string describing the error in a human-readable form
Return Value

None

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

Loading Code Sample...