Most visited

Recently visited

Added in API level 23

PhoneAccount

public final class PhoneAccount
extends Object implements Parcelable

java.lang.Object
   ↳ android.telecom.PhoneAccount


Represents a distinct method to place or receive a phone call. Apps which can place calls and want those calls to be integrated into the dialer and in-call UI should build an instance of this class and register it with the system using TelecomManager.

TelecomManager uses registered PhoneAccounts to present the user with alternative options when placing a phone call. When building a PhoneAccount, the app should supply a valid PhoneAccountHandle that references the connection service implementation Telecom will use to interact with the app.

Summary

Nested classes

class PhoneAccount.Builder

Helper class for creating a PhoneAccount

Constants

int CAPABILITY_CALL_PROVIDER

Flag indicating that this PhoneAccount can make phone calls in place of traditional SIM-based telephony calls.

int CAPABILITY_CALL_SUBJECT

Flag indicating that this PhoneAccount supports a subject for Calls.

int CAPABILITY_CONNECTION_MANAGER

Flag indicating that this PhoneAccount can act as a connection manager for other connections.

int CAPABILITY_PLACE_EMERGENCY_CALLS

Flag indicating that this PhoneAccount is capable of placing emergency calls.

int CAPABILITY_SIM_SUBSCRIPTION

Flag indicating that this PhoneAccount represents a built-in PSTN SIM subscription.

int CAPABILITY_VIDEO_CALLING

Flag indicating that this PhoneAccount is capable of placing video calls.

int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE

Flag indicating that for this PhoneAccount, the ability to make a video call to a number relies on presence.

String EXTRA_CALL_SUBJECT_CHARACTER_ENCODING

PhoneAccount extras key (see getExtras()) which determines the character encoding to be used when determining the length of messages.

String EXTRA_CALL_SUBJECT_MAX_LENGTH

PhoneAccount extras key (see getExtras()) which determines the maximum permitted length of a call subject specified via the EXTRA_CALL_SUBJECT extra on an ACTION_CALL intent.

int NO_HIGHLIGHT_COLOR

Indicating no hightlight color is set.

int NO_RESOURCE_ID

Indicating no resource ID is set.

String SCHEME_SIP

URI scheme for SIP URIs.

String SCHEME_TEL

URI scheme for telephone number URIs.

String SCHEME_VOICEMAIL

URI scheme for voicemail URIs.

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<PhoneAccount> CREATOR

Public methods

static PhoneAccount.Builder builder(PhoneAccountHandle accountHandle, CharSequence label)
int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

PhoneAccountHandle getAccountHandle()

The unique identifier of this PhoneAccount.

Uri getAddress()

The address (e.g., a phone number) associated with this PhoneAccount.

int getCapabilities()

The capabilities of this PhoneAccount.

Bundle getExtras()

The extras associated with this PhoneAccount.

int getHighlightColor()

A highlight color to use in displaying information about this PhoneAccount.

Icon getIcon()

The icon to represent this PhoneAccount.

CharSequence getLabel()

A short label describing a PhoneAccount.

CharSequence getShortDescription()

A short paragraph describing this PhoneAccount.

Uri getSubscriptionAddress()

The raw callback number used for this PhoneAccount, as distinct from getAddress().

List<String> getSupportedUriSchemes()

The URI schemes supported by this PhoneAccount.

boolean hasCapabilities(int capability)

Determines if this PhoneAccount has a capabilities specified by the passed in bit mask.

boolean isEnabled()

Indicates whether the user has enabled this PhoneAccount or not.

boolean supportsUriScheme(String uriScheme)

Determines if the PhoneAccount supports calls to/from addresses with a specified URI scheme.

PhoneAccount.Builder toBuilder()

Returns a builder initialized with the current PhoneAccount instance.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel out, int flags)

Flatten this object in to a Parcel.

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Constants

CAPABILITY_CALL_PROVIDER

Added in API level 23
int CAPABILITY_CALL_PROVIDER

Flag indicating that this PhoneAccount can make phone calls in place of traditional SIM-based telephony calls. This account will be treated as a distinct method for placing calls alongside the traditional SIM-based telephony stack. This flag is distinct from CAPABILITY_CONNECTION_MANAGER in that it is not allowed to manage or place calls from the built-in telephony stack.

See getCapabilities()

Constant Value: 2 (0x00000002)

CAPABILITY_CALL_SUBJECT

Added in API level 23
int CAPABILITY_CALL_SUBJECT

Flag indicating that this PhoneAccount supports a subject for Calls. This means a caller is able to specify a short subject line for an outgoing call. A capable receiving device displays the call subject on the incoming call screen.

See getCapabilities()

Constant Value: 64 (0x00000040)

CAPABILITY_CONNECTION_MANAGER

Added in API level 23
int CAPABILITY_CONNECTION_MANAGER

Flag indicating that this PhoneAccount can act as a connection manager for other connections. The ConnectionService associated with this PhoneAccount will be allowed to manage phone calls including using its own proprietary phone-call implementation (like VoIP calling) to make calls instead of the telephony stack.

When a user opts to place a call using the SIM-based telephony stack, the ConnectionService associated with this PhoneAccount will be attempted first if the user has explicitly selected it to be used as the default connection manager.

See getCapabilities()

Constant Value: 1 (0x00000001)

CAPABILITY_PLACE_EMERGENCY_CALLS

Added in API level 23
int CAPABILITY_PLACE_EMERGENCY_CALLS

Flag indicating that this PhoneAccount is capable of placing emergency calls. By default all PSTN PhoneAccounts are capable of placing emergency calls.

See getCapabilities()

Constant Value: 16 (0x00000010)

CAPABILITY_SIM_SUBSCRIPTION

Added in API level 23
int CAPABILITY_SIM_SUBSCRIPTION

Flag indicating that this PhoneAccount represents a built-in PSTN SIM subscription.

Only the Android framework can register a PhoneAccount having this capability.

See getCapabilities()

Constant Value: 4 (0x00000004)

CAPABILITY_VIDEO_CALLING

Added in API level 23
int CAPABILITY_VIDEO_CALLING

Flag indicating that this PhoneAccount is capable of placing video calls.

See getCapabilities()

Constant Value: 8 (0x00000008)

CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE

Added in API level 24
int CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE

Flag indicating that for this PhoneAccount, the ability to make a video call to a number relies on presence. Should only be set if the PhoneAccount also has CAPABILITY_VIDEO_CALLING.

When set, the ConnectionService is responsible for toggling the CARRIER_PRESENCE_VT_CAPABLE bit on the CARRIER_PRESENCE column to indicate whether a contact's phone number supports video calling.

See getCapabilities()

Constant Value: 256 (0x00000100)

EXTRA_CALL_SUBJECT_CHARACTER_ENCODING

Added in API level 24
String EXTRA_CALL_SUBJECT_CHARACTER_ENCODING

PhoneAccount extras key (see getExtras()) which determines the character encoding to be used when determining the length of messages. The user interface can use this when determining the number of characters the user may type in a call subject. If empty-string, the call subject message size limit will be enforced on a 1:1 basis. That is, each character will count towards the messages size limit as a single character. If a character encoding is specified, the message size limit will be based on the number of bytes in the message per the specified encoding. See EXTRA_CALL_SUBJECT_MAX_LENGTH for more information on the call subject maximum length.

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

EXTRA_CALL_SUBJECT_MAX_LENGTH

Added in API level 24
String EXTRA_CALL_SUBJECT_MAX_LENGTH

PhoneAccount extras key (see getExtras()) which determines the maximum permitted length of a call subject specified via the EXTRA_CALL_SUBJECT extra on an ACTION_CALL intent. Ultimately a ConnectionService is responsible for enforcing the maximum call subject length when sending the message, however this extra is provided so that the user interface can proactively limit the length of the call subject as the user types it.

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

NO_HIGHLIGHT_COLOR

Added in API level 23
int NO_HIGHLIGHT_COLOR

Indicating no hightlight color is set.

Constant Value: 0 (0x00000000)

NO_RESOURCE_ID

Added in API level 23
int NO_RESOURCE_ID

Indicating no resource ID is set.

Constant Value: -1 (0xffffffff)

SCHEME_SIP

Added in API level 23
String SCHEME_SIP

URI scheme for SIP URIs.

Constant Value: "sip"

SCHEME_TEL

Added in API level 23
String SCHEME_TEL

URI scheme for telephone number URIs.

Constant Value: "tel"

SCHEME_VOICEMAIL

Added in API level 23
String SCHEME_VOICEMAIL

URI scheme for voicemail URIs.

Constant Value: "voicemail"

Fields

CREATOR

Added in API level 23
Creator<PhoneAccount> CREATOR

Public methods

builder

Added in API level 23
PhoneAccount.Builder builder (PhoneAccountHandle accountHandle, 
                CharSequence label)

Parameters
accountHandle PhoneAccountHandle
label CharSequence
Returns
PhoneAccount.Builder

describeContents

Added in API level 23
int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getAccountHandle

Added in API level 23
PhoneAccountHandle getAccountHandle ()

The unique identifier of this PhoneAccount.

Returns
PhoneAccountHandle A PhoneAccountHandle.

getAddress

Added in API level 23
Uri getAddress ()

The address (e.g., a phone number) associated with this PhoneAccount. This represents the destination from which outgoing calls using this PhoneAccount will appear to come, if applicable, and the destination to which incoming calls using this PhoneAccount may be addressed.

Returns
Uri A address expressed as a Uri, for example, a phone number.

getCapabilities

Added in API level 23
int getCapabilities ()

The capabilities of this PhoneAccount.

Returns
int A bit field of flags describing this PhoneAccount's capabilities.

getExtras

Added in API level 24
Bundle getExtras ()

The extras associated with this PhoneAccount.

A ConnectionService may provide implementation specific information about the PhoneAccount via the extras.

Returns
Bundle The extras.

getHighlightColor

Added in API level 23
int getHighlightColor ()

A highlight color to use in displaying information about this PhoneAccount.

Returns
int A hexadecimal color value.

getIcon

Added in API level 23
Icon getIcon ()

The icon to represent this PhoneAccount.

Returns
Icon The icon.

getLabel

Added in API level 23
CharSequence getLabel ()

A short label describing a PhoneAccount.

Returns
CharSequence A label for this PhoneAccount.

getShortDescription

Added in API level 23
CharSequence getShortDescription ()

A short paragraph describing this PhoneAccount.

Returns
CharSequence A description for this PhoneAccount.

getSubscriptionAddress

Added in API level 23
Uri getSubscriptionAddress ()

The raw callback number used for this PhoneAccount, as distinct from getAddress(). For the majority of PhoneAccounts this should be registered as null. It is used by the system for SIM-based PhoneAccount registration where setLine1NumberForDisplay(String, String) has been used to alter the callback number.

Returns
Uri The subscription number, suitable for display to the user.

getSupportedUriSchemes

Added in API level 23
List<String> getSupportedUriSchemes ()

The URI schemes supported by this PhoneAccount.

Returns
List<String> The URI schemes.

hasCapabilities

Added in API level 23
boolean hasCapabilities (int capability)

Determines if this PhoneAccount has a capabilities specified by the passed in bit mask.

Parameters
capability int: The capabilities to check.
Returns
boolean true if the phone account has the capability.

isEnabled

Added in API level 23
boolean isEnabled ()

Indicates whether the user has enabled this PhoneAccount or not. This value is only populated for PhoneAccounts returned by getPhoneAccount(PhoneAccountHandle).

Returns
boolean true if the account is enabled by the user, false otherwise.

supportsUriScheme

Added in API level 23
boolean supportsUriScheme (String uriScheme)

Determines if the PhoneAccount supports calls to/from addresses with a specified URI scheme.

Parameters
uriScheme String: The URI scheme to check.
Returns
boolean true if the PhoneAccount supports calls to/from addresses with the specified URI scheme.

toBuilder

Added in API level 23
PhoneAccount.Builder toBuilder ()

Returns a builder initialized with the current PhoneAccount instance.

Returns
PhoneAccount.Builder The builder.

toString

Added in API level 23
String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

Added in API level 23
void writeToParcel (Parcel out, 
                int flags)

Flatten this object in to a Parcel.

Parameters
out Parcel: The Parcel in which the object should be written.
flags int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.

Hooray!