Android APIs
public class

TelecomManager

extends Object
java.lang.Object
   ↳ android.telecom.TelecomManager

Class Overview

Provides access to information about active calls and registration/call-management functionality. Apps can use methods in this class to determine the current call state.

Apps do not instantiate this class directly; instead, they retrieve a reference to an instance through Context.getSystemService(Context.TELECOM_SERVICE).

Note that access to some telecom information is permission-protected. Your app cannot access the protected information or gain access to protected functionality unless it has the appropriate permissions declared in its manifest file. Where permissions apply, they are noted in the method descriptions.

Summary

Constants
String ACTION_CHANGE_DEFAULT_DIALER Activity action: Shows a dialog asking the user whether or not they want to replace the current default Dialer with the one specified in EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME.
String ACTION_CHANGE_PHONE_ACCOUNTS The Intent action used to show the settings page used to configure PhoneAccount preferences.
String ACTION_CONFIGURE_PHONE_ACCOUNT An Intent action sent by the telecom framework to start a configuration dialog for a registered PhoneAccount.
String ACTION_DEFAULT_DIALER_CHANGED Broadcast intent action indicating that the current default dialer has changed.
String ACTION_INCOMING_CALL Activity action: Starts the UI for handing an incoming call.
String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS The Intent action used to show the call accessibility settings page.
String ACTION_SHOW_CALL_SETTINGS The Intent action used to show the call settings page.
String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS The Intent action used to show the respond via SMS settings page.
char DTMF_CHARACTER_PAUSE The dual tone multi-frequency signaling character sent to indicate the dialing system should pause for a predefined period.
char DTMF_CHARACTER_WAIT The dual-tone multi-frequency signaling character sent to indicate the dialing system should wait for user confirmation before proceeding.
String EXTRA_CALL_BACK_NUMBER The number which the party on the other side of the line will see (and use to return the call).
String EXTRA_CALL_DISCONNECT_CAUSE Optional extra for ACTION_PHONE_STATE_CHANGED containing the disconnect code.
String EXTRA_CALL_DISCONNECT_MESSAGE Optional extra for ACTION_PHONE_STATE_CHANGED containing the disconnect message.
String EXTRA_CALL_SUBJECT Optional extra for ACTION_CALL containing a string call subject which will be associated with an outgoing call.
String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME Extra value used to provide the package name for ACTION_CHANGE_DEFAULT_DIALER.
String EXTRA_INCOMING_CALL_ADDRESS The extra used by a ConnectionService to provide the handle of the caller that has initiated a new incoming call.
String EXTRA_INCOMING_CALL_EXTRAS Optional extra for ACTION_INCOMING_CALL containing a Bundle which contains metadata about the call.
String EXTRA_OUTGOING_CALL_EXTRAS Optional extra for ACTION_CALL and ACTION_DIAL Intent containing a Bundle which contains metadata about the call.
String EXTRA_PHONE_ACCOUNT_HANDLE The extra used with an ACTION_CALL and ACTION_DIAL Intent to specify a PhoneAccountHandle to use when making the call.
String EXTRA_START_CALL_WITH_SPEAKERPHONE Optional extra for ACTION_CALL containing a boolean that determines whether the speakerphone should be automatically turned on for an outgoing call.
String EXTRA_START_CALL_WITH_VIDEO_STATE Optional extra for ACTION_CALL containing an integer that determines the desired video state for an outgoing call.
String GATEWAY_ORIGINAL_ADDRESS An optional ACTION_CALL intent extra corresponding to the original address to dial for the call.
String GATEWAY_PROVIDER_PACKAGE An optional ACTION_CALL intent extra denoting the package name of the app specifying an alternative gateway for the call.
String METADATA_IN_CALL_SERVICE_UI A boolean meta-data value indicating whether an InCallService implements an in-call user interface.
int PRESENTATION_ALLOWED Indicates that the address or number of a call is allowed to be displayed for caller ID.
int PRESENTATION_PAYPHONE Indicates that the address or number of a call belongs to a pay phone.
int PRESENTATION_RESTRICTED Indicates that the address or number of a call is blocked by the other party.
int PRESENTATION_UNKNOWN Indicates that the address or number of a call is not specified or known by the carrier.
Public Methods
void addNewIncomingCall(PhoneAccountHandle phoneAccount, Bundle extras)
Registers a new incoming call.
void cancelMissedCallsNotification()
Removes the missed-call notification if one is present.
Uri getAdnUriForPhoneAccount(PhoneAccountHandle accountHandle)
List<PhoneAccountHandle> getCallCapablePhoneAccounts()
Returns a list of PhoneAccountHandles which can be used to make and receive phone calls.
String getDefaultDialerPackage()
Used to determine the currently selected default dialer package.
PhoneAccountHandle getDefaultOutgoingPhoneAccount(String uriScheme)
Return the PhoneAccount which will be used to place outgoing calls to addresses with the specified uriScheme.
String getLine1Number(PhoneAccountHandle accountHandle)
Return the line 1 phone number for given phone account.
PhoneAccount getPhoneAccount(PhoneAccountHandle account)
Return the PhoneAccount for a specified PhoneAccountHandle.
PhoneAccountHandle getSimCallManager()
Returns the current SIM call manager.
String getVoiceMailNumber(PhoneAccountHandle accountHandle)
Return the voicemail number for a given phone account.
boolean handleMmi(String dialString)
Processes the specified dial string as an MMI code.
boolean handleMmi(String dialString, PhoneAccountHandle accountHandle)
Processes the specified dial string as an MMI code.
boolean isInCall()
Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding states).
boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number)
Return whether a given phone number is the configured voicemail number for a particular phone account.
void placeCall(Uri address, Bundle extras)
Places a new outgoing call to the provided address using the system telecom service with the specified extras.
void registerPhoneAccount(PhoneAccount account)
Register a PhoneAccount for use by the system.
void showInCallScreen(boolean showDialpad)
Brings the in-call screen to the foreground if there is an ongoing call.
void silenceRinger()
Silences the ringer if a ringing call exists.
void unregisterPhoneAccount(PhoneAccountHandle accountHandle)
Remove a PhoneAccount registration from the system.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_CHANGE_DEFAULT_DIALER

Added in API level 23

Activity action: Shows a dialog asking the user whether or not they want to replace the current default Dialer with the one specified in EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME. Usage example:

 Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
 intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,
         getActivity().getPackageName());
 startActivity(intent);
 

Constant Value: "android.telecom.action.CHANGE_DEFAULT_DIALER"

public static final String ACTION_CHANGE_PHONE_ACCOUNTS

Added in API level 23

The Intent action used to show the settings page used to configure PhoneAccount preferences.

Constant Value: "android.telecom.action.CHANGE_PHONE_ACCOUNTS"

public static final String ACTION_CONFIGURE_PHONE_ACCOUNT

Added in API level 23

An Intent action sent by the telecom framework to start a configuration dialog for a registered PhoneAccount. There is no default dialog and each app that registers a PhoneAccount should provide one if desired.

A user can access the list of enabled PhoneAccounts through the Phone app's settings menu. For each entry, the settings app will add a click action. When triggered, the click-action will start this intent along with the extra EXTRA_PHONE_ACCOUNT_HANDLE to indicate the PhoneAccount to configure. If the PhoneAccount package does not register an Activity for this intent, then it will not be sent.

Constant Value: "android.telecom.action.CONFIGURE_PHONE_ACCOUNT"

public static final String ACTION_DEFAULT_DIALER_CHANGED

Added in API level 23

Broadcast intent action indicating that the current default dialer has changed. The string extra EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME will contain the name of the package that the default dialer was changed to.

Constant Value: "android.telecom.action.DEFAULT_DIALER_CHANGED"

public static final String ACTION_INCOMING_CALL

Added in API level 23

Activity action: Starts the UI for handing an incoming call. This intent starts the in-call UI by notifying the Telecom system that an incoming call exists for a specific call service (see ConnectionService). Telecom reads the Intent extras to find and bind to the appropriate ConnectionService which Telecom will ultimately use to control and get information about the call.

Input: get*Extra field EXTRA_PHONE_ACCOUNT_HANDLE contains the component name of the ConnectionService that Telecom should bind to. Telecom will then ask the connection service for more information about the call prior to showing any UI.

Constant Value: "android.telecom.action.INCOMING_CALL"

public static final String ACTION_SHOW_CALL_ACCESSIBILITY_SETTINGS

Added in API level 23

The Intent action used to show the call accessibility settings page.

Constant Value: "android.telecom.action.SHOW_CALL_ACCESSIBILITY_SETTINGS"

public static final String ACTION_SHOW_CALL_SETTINGS

Added in API level 21

The Intent action used to show the call settings page.

Constant Value: "android.telecom.action.SHOW_CALL_SETTINGS"

public static final String ACTION_SHOW_RESPOND_VIA_SMS_SETTINGS

Added in API level 23

The Intent action used to show the respond via SMS settings page.

Constant Value: "android.telecom.action.SHOW_RESPOND_VIA_SMS_SETTINGS"

public static final char DTMF_CHARACTER_PAUSE

Added in API level 21

The dual tone multi-frequency signaling character sent to indicate the dialing system should pause for a predefined period.

Constant Value: 44 (0x0000002c)

public static final char DTMF_CHARACTER_WAIT

Added in API level 21

The dual-tone multi-frequency signaling character sent to indicate the dialing system should wait for user confirmation before proceeding.

Constant Value: 59 (0x0000003b)

public static final String EXTRA_CALL_BACK_NUMBER

Added in API level 23

The number which the party on the other side of the line will see (and use to return the call).

ConnectionServices which interact with RemoteConnections should only populate this if the getLine1Number() value, as that is the user's expected caller ID.

Constant Value: "android.telecom.extra.CALL_BACK_NUMBER"

public static final String EXTRA_CALL_DISCONNECT_CAUSE

Added in API level 21

Optional extra for ACTION_PHONE_STATE_CHANGED containing the disconnect code.

Constant Value: "android.telecom.extra.CALL_DISCONNECT_CAUSE"

public static final String EXTRA_CALL_DISCONNECT_MESSAGE

Added in API level 21

Optional extra for ACTION_PHONE_STATE_CHANGED containing the disconnect message.

Constant Value: "android.telecom.extra.CALL_DISCONNECT_MESSAGE"

public static final String EXTRA_CALL_SUBJECT

Added in API level 23

Optional extra for ACTION_CALL containing a string call subject which will be associated with an outgoing call. Should only be specified if the PhoneAccount supports the capability CAPABILITY_CALL_SUBJECT.

Constant Value: "android.telecom.extra.CALL_SUBJECT"

public static final String EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME

Added in API level 23

Extra value used to provide the package name for ACTION_CHANGE_DEFAULT_DIALER.

Constant Value: "android.telecom.extra.CHANGE_DEFAULT_DIALER_PACKAGE_NAME"

public static final String EXTRA_INCOMING_CALL_ADDRESS

Added in API level 23

The extra used by a ConnectionService to provide the handle of the caller that has initiated a new incoming call.

Constant Value: "android.telecom.extra.INCOMING_CALL_ADDRESS"

public static final String EXTRA_INCOMING_CALL_EXTRAS

Added in API level 23

Optional extra for ACTION_INCOMING_CALL containing a Bundle which contains metadata about the call. This Bundle will be returned to the ConnectionService.

Constant Value: "android.telecom.extra.INCOMING_CALL_EXTRAS"

public static final String EXTRA_OUTGOING_CALL_EXTRAS

Added in API level 23

Optional extra for ACTION_CALL and ACTION_DIAL Intent containing a Bundle which contains metadata about the call. This Bundle will be saved into Call.Details and passed to the ConnectionService when placing the call.

Constant Value: "android.telecom.extra.OUTGOING_CALL_EXTRAS"

public static final String EXTRA_PHONE_ACCOUNT_HANDLE

Added in API level 23

The extra used with an ACTION_CALL and ACTION_DIAL Intent to specify a PhoneAccountHandle to use when making the call.

Retrieve with getParcelableExtra(String).

Constant Value: "android.telecom.extra.PHONE_ACCOUNT_HANDLE"

public static final String EXTRA_START_CALL_WITH_SPEAKERPHONE

Added in API level 21

Optional extra for ACTION_CALL containing a boolean that determines whether the speakerphone should be automatically turned on for an outgoing call.

Constant Value: "android.telecom.extra.START_CALL_WITH_SPEAKERPHONE"

public static final String EXTRA_START_CALL_WITH_VIDEO_STATE

Added in API level 23

Optional extra for ACTION_CALL containing an integer that determines the desired video state for an outgoing call. Valid options: STATE_AUDIO_ONLY, STATE_BIDIRECTIONAL, STATE_RX_ENABLED, STATE_TX_ENABLED.

Constant Value: "android.telecom.extra.START_CALL_WITH_VIDEO_STATE"

public static final String GATEWAY_ORIGINAL_ADDRESS

Added in API level 21

An optional ACTION_CALL intent extra corresponding to the original address to dial for the call. This is used when an alternative gateway address is provided to recall the original address. The value is a Uri. (See GATEWAY_PROVIDER_PACKAGE for details)

Constant Value: "android.telecom.extra.GATEWAY_ORIGINAL_ADDRESS"

public static final String GATEWAY_PROVIDER_PACKAGE

Added in API level 21

An optional ACTION_CALL intent extra denoting the package name of the app specifying an alternative gateway for the call. The value is a string. (The following comment corresponds to the all GATEWAY_* extras) An app which sends the ACTION_CALL intent can specify an alternative address to dial which is different from the one specified and displayed to the user. This alternative address is referred to as the gateway address.

Constant Value: "android.telecom.extra.GATEWAY_PROVIDER_PACKAGE"

public static final String METADATA_IN_CALL_SERVICE_UI

Added in API level 23

A boolean meta-data value indicating whether an InCallService implements an in-call user interface. Dialer implementations (see getDefaultDialerPackage()) which would also like to replace the in-call interface should set this meta-data to true in the manifest registration of their InCallService.

Constant Value: "android.telecom.IN_CALL_SERVICE_UI"

public static final int PRESENTATION_ALLOWED

Added in API level 21

Indicates that the address or number of a call is allowed to be displayed for caller ID.

Constant Value: 1 (0x00000001)

public static final int PRESENTATION_PAYPHONE

Added in API level 21

Indicates that the address or number of a call belongs to a pay phone.

Constant Value: 4 (0x00000004)

public static final int PRESENTATION_RESTRICTED

Added in API level 21

Indicates that the address or number of a call is blocked by the other party.

Constant Value: 2 (0x00000002)

public static final int PRESENTATION_UNKNOWN

Added in API level 21

Indicates that the address or number of a call is not specified or known by the carrier.

Constant Value: 3 (0x00000003)

Public Methods

public void addNewIncomingCall (PhoneAccountHandle phoneAccount, Bundle extras)

Added in API level 23

Registers a new incoming call. A ConnectionService should invoke this method when it has an incoming call. The specified PhoneAccountHandle must have been registered with registerPhoneAccount(PhoneAccount). Once invoked, this method will cause the system to bind to the ConnectionService associated with the PhoneAccountHandle and request additional information about the call (See onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)) before starting the incoming call UI.

Parameters
phoneAccount A PhoneAccountHandle registered with registerPhoneAccount(PhoneAccount).
extras A bundle that will be passed through to onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest).

public void cancelMissedCallsNotification ()

Added in API level 21

Removes the missed-call notification if one is present.

Requires that the method-caller be set as the system dialer app.

public Uri getAdnUriForPhoneAccount (PhoneAccountHandle accountHandle)

Added in API level 23

Parameters
accountHandle The handle for the account to derive an adn query URI for or null to return a URI which will use the default account.
Returns
  • The URI (with the content:// scheme) specific to the specified PhoneAccount for the the content retrieve.

public List<PhoneAccountHandle> getCallCapablePhoneAccounts ()

Added in API level 23

Returns a list of PhoneAccountHandles which can be used to make and receive phone calls. The returned list includes only those accounts which have been explicitly enabled by the user.

Returns
  • A list of PhoneAccountHandle objects.

public String getDefaultDialerPackage ()

Added in API level 23

Used to determine the currently selected default dialer package.

Returns
  • package name for the default dialer package or null if no package has been selected as the default dialer.

public PhoneAccountHandle getDefaultOutgoingPhoneAccount (String uriScheme)

Added in API level 23

Return the PhoneAccount which will be used to place outgoing calls to addresses with the specified uriScheme. This PhoneAccount will always be a member of the list which is returned from invoking getCallCapablePhoneAccounts(). The specific account returned depends on the following priorities:

  • If the user-selected default PhoneAccount supports the specified scheme, it will be returned.
  • If there exists only one PhoneAccount that supports the specified scheme, it will be returned.

If no PhoneAccount fits the criteria above, this method will return null.

Parameters
uriScheme The URI scheme.
Returns

public String getLine1Number (PhoneAccountHandle accountHandle)

Added in API level 23

Return the line 1 phone number for given phone account.

Parameters
accountHandle The handle for the account retrieve a number for.
Returns
  • A string representation of the line 1 phone number.

public PhoneAccount getPhoneAccount (PhoneAccountHandle account)

Added in API level 23

Return the PhoneAccount for a specified PhoneAccountHandle. Object includes resources which can be used in a user interface.

Parameters
account The PhoneAccountHandle.
Returns

public PhoneAccountHandle getSimCallManager ()

Added in API level 23

Returns the current SIM call manager. Apps must be prepared for this method to return null, indicating that there currently exists no user-chosen default PhoneAccount.

Returns
  • The phone account handle of the current sim call manager.

public String getVoiceMailNumber (PhoneAccountHandle accountHandle)

Added in API level 23

Return the voicemail number for a given phone account.

Parameters
accountHandle The handle for the phone account.
Returns
  • The voicemail number for the phone account, and null if one has not been configured.

public boolean handleMmi (String dialString)

Added in API level 21

Processes the specified dial string as an MMI code. MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". Some of these sequences launch special behavior through handled by Telephony. This method uses the default subscription.

Requires that the method-caller be set as the system dialer app.

Parameters
dialString The digits to dial.
Returns
  • True if the digits were processed as an MMI code, false otherwise.

public boolean handleMmi (String dialString, PhoneAccountHandle accountHandle)

Added in API level 23

Processes the specified dial string as an MMI code. MMI codes are any sequence of characters entered into the dialpad that contain a "*" or "#". Some of these sequences launch special behavior through handled by Telephony.

Requires that the method-caller be set as the system dialer app.

Parameters
dialString The digits to dial.
accountHandle The handle for the account the MMI code should apply to.
Returns
  • True if the digits were processed as an MMI code, false otherwise.

public boolean isInCall ()

Added in API level 21

Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding states).

Requires permission: READ_PHONE_STATE

public boolean isVoiceMailNumber (PhoneAccountHandle accountHandle, String number)

Added in API level 23

Return whether a given phone number is the configured voicemail number for a particular phone account.

Parameters
accountHandle The handle for the account to check the voicemail number against
number The number to look up.

public void placeCall (Uri address, Bundle extras)

Added in API level 23

Places a new outgoing call to the provided address using the system telecom service with the specified extras. This method is equivalent to placing an outgoing call using ACTION_CALL, except that the outgoing call will always be sent via the system telecom service. If method-caller is either the user selected default dialer app or preloaded system dialer app, then emergency calls will also be allowed. Requires permission: CALL_PHONE Usage example:

 Uri uri = Uri.fromParts("tel", "12345", null);
 Bundle extras = new Bundle();
 extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true);
 telecomManager.placeCall(uri, extras);
 
The following keys are supported in the supplied extras.

Parameters
address The address to make the call to.
extras Bundle of extras to use with the call.

public void registerPhoneAccount (PhoneAccount account)

Added in API level 23

Register a PhoneAccount for use by the system. When registering PhoneAccounts, existing registrations will be overwritten if the PhoneAccountHandle matches that of a PhoneAccount which is already registered. Once registered, the PhoneAccount is listed to the user as an option when placing calls. The user may still need to enable the PhoneAccount within the phone app settings before the account is usable.

A SecurityException will be thrown if an app tries to register a PhoneAccountHandle where the package name specified within getComponentName() does not match the package name of the app.

Parameters
account The complete PhoneAccount.

public void showInCallScreen (boolean showDialpad)

Added in API level 21

Brings the in-call screen to the foreground if there is an ongoing call. If there is currently no ongoing call, then this method does nothing.

Requires that the method-caller be set as the system dialer app or have the READ_PHONE_STATE permission.

Parameters
showDialpad Brings up the in-call dialpad as part of showing the in-call screen.

public void silenceRinger ()

Added in API level 23

Silences the ringer if a ringing call exists.

public void unregisterPhoneAccount (PhoneAccountHandle accountHandle)

Added in API level 23

Remove a PhoneAccount registration from the system.

Parameters
accountHandle A PhoneAccountHandle for the PhoneAccount to unregister.