Most visited

Recently visited

Added in API level 1

TelephonyManager

public class TelephonyManager
extends Object

java.lang.Object
   ↳ android.telephony.TelephonyManager


Provides access to information about the telephony services on the device. Applications can use the methods in this class to determine telephony services and states, as well as to access some types of subscriber information. Applications can also register a listener to receive notification of telephony state changes.

You do not instantiate this class directly; instead, you retrieve a reference to an instance through Context.getSystemService(Context.TELEPHONY_SERVICE). The returned TelephonyManager will use the default subscription for all calls. To call an API for a specific subscription, use createForSubscriptionId(int). e.g. telephonyManager = defaultSubTelephonyManager.createForSubscriptionId(subId);

Note that access to some telephony information is permission-protected. Your application cannot access the protected information unless it has the appropriate permissions declared in its manifest file. Where permissions apply, they are noted in the the methods through which you access the protected information.

Summary

Constants

String ACTION_CONFIGURE_VOICEMAIL

Open the voicemail settings activity to make changes to voicemail configuration.

String ACTION_PHONE_STATE_CHANGED

Broadcast intent action indicating that the call state on the device has changed.

String ACTION_RESPOND_VIA_MESSAGE

The Phone app sends this intent when a user opts to respond-via-message during an incoming call.

int APPTYPE_CSIM

UICC application type is CSIM

int APPTYPE_ISIM

UICC application type is ISIM

int APPTYPE_RUIM

UICC application type is RUIM

int APPTYPE_SIM

UICC application type is SIM

int APPTYPE_USIM

UICC application type is USIM

int AUTHTYPE_EAP_AKA

Authentication type for UICC challenge is EAP AKA.

int AUTHTYPE_EAP_SIM

Authentication type for UICC challenge is EAP SIM.

int CALL_STATE_IDLE

Device call state: No activity.

int CALL_STATE_OFFHOOK

Device call state: Off-hook.

int CALL_STATE_RINGING

Device call state: Ringing.

int DATA_ACTIVITY_DORMANT

Data connection is active, but physical link is down

int DATA_ACTIVITY_IN

Data connection activity: Currently receiving IP PPP traffic.

int DATA_ACTIVITY_INOUT

Data connection activity: Currently both sending and receiving IP PPP traffic.

int DATA_ACTIVITY_NONE

Data connection activity: No traffic.

int DATA_ACTIVITY_OUT

Data connection activity: Currently sending IP PPP traffic.

int DATA_CONNECTED

Data connection state: Connected.

int DATA_CONNECTING

Data connection state: Currently setting up a data connection.

int DATA_DISCONNECTED

Data connection state: Disconnected.

int DATA_SUSPENDED

Data connection state: Suspended.

String EXTRA_INCOMING_NUMBER

The lookup key used with the ACTION_PHONE_STATE_CHANGED broadcast for a String containing the incoming phone number.

String EXTRA_STATE

The lookup key used with the ACTION_PHONE_STATE_CHANGED broadcast for a String containing the new call state.

int NETWORK_TYPE_1xRTT

Current network is 1xRTT

int NETWORK_TYPE_CDMA

Current network is CDMA: Either IS95A or IS95B

int NETWORK_TYPE_EDGE

Current network is EDGE

int NETWORK_TYPE_EHRPD

Current network is eHRPD

int NETWORK_TYPE_EVDO_0

Current network is EVDO revision 0

int NETWORK_TYPE_EVDO_A

Current network is EVDO revision A

int NETWORK_TYPE_EVDO_B

Current network is EVDO revision B

int NETWORK_TYPE_GPRS

Current network is GPRS

int NETWORK_TYPE_HSDPA

Current network is HSDPA

int NETWORK_TYPE_HSPA

Current network is HSPA

int NETWORK_TYPE_HSPAP

Current network is HSPA+

int NETWORK_TYPE_HSUPA

Current network is HSUPA

int NETWORK_TYPE_IDEN

Current network is iDen

int NETWORK_TYPE_LTE

Current network is LTE

int NETWORK_TYPE_UMTS

Current network is UMTS

int NETWORK_TYPE_UNKNOWN

Network type is unknown

int PHONE_TYPE_CDMA

Phone radio is CDMA.

int PHONE_TYPE_GSM

Phone radio is GSM.

int PHONE_TYPE_NONE

No phone radio.

int PHONE_TYPE_SIP

Phone is via SIP.

int SIM_STATE_ABSENT

SIM card state: no SIM card is available in the device

int SIM_STATE_NETWORK_LOCKED

SIM card state: Locked: requires a network PIN to unlock

int SIM_STATE_PIN_REQUIRED

SIM card state: Locked: requires the user's SIM PIN to unlock

int SIM_STATE_PUK_REQUIRED

SIM card state: Locked: requires the user's SIM PUK to unlock

int SIM_STATE_READY

SIM card state: Ready

int SIM_STATE_UNKNOWN

SIM card state: Unknown.

String VVM_TYPE_CVVM

A flavor of OMTP protocol with a different mobile originated (MO) format

String VVM_TYPE_OMTP

The OMTP protocol.

Fields

public static final String EXTRA_STATE_IDLE

Value used with EXTRA_STATE corresponding to CALL_STATE_IDLE.

public static final String EXTRA_STATE_OFFHOOK

Value used with EXTRA_STATE corresponding to CALL_STATE_OFFHOOK.

public static final String EXTRA_STATE_RINGING

Value used with EXTRA_STATE corresponding to CALL_STATE_RINGING.

Public methods

boolean canChangeDtmfToneLength()

Whether the device supports configuring the DTMF tone length.

TelephonyManager createForSubscriptionId(int subId)

Create a new TelephonyManager object pinned to the given subscription ID.

List<CellInfo> getAllCellInfo()

Returns all observed cell information from all radios on the device including the primary and neighboring cells.

int getCallState()

Returns one of the following constants that represents the current state of all phone calls.

CellLocation getCellLocation()

Returns the current location of the device.

int getDataActivity()

Returns a constant indicating the type of activity on a data connection (cellular).

int getDataNetworkType()

Returns a constant indicating the radio technology (network type) currently in use on the device for data transmission.

int getDataState()

Returns a constant indicating the current data connection state (cellular).

String getDeviceId()

Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones.

String getDeviceId(int slotId)

Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones.

String getDeviceSoftwareVersion()

Returns the software version number for the device, for example, the IMEI/SV for GSM phones.

String getGroupIdLevel1()

Returns the Group Identifier Level1 for a GSM phone.

String getIccAuthentication(int appType, int authType, String data)

Returns the response of authentication for the default subscription.

String getLine1Number()

Returns the phone number string for line 1, for example, the MSISDN for a GSM phone.

String getMmsUAProfUrl()

Returns the MMS user agent profile URL.

String getMmsUserAgent()

Returns the MMS user agent.

List<NeighboringCellInfo> getNeighboringCellInfo()

This method was deprecated in API level 23. Use (@link getAllCellInfo} which returns a superset of the information from NeighboringCellInfo.

String getNetworkCountryIso()

Returns the ISO country code equivalent of the current registered operator's MCC (Mobile Country Code).

String getNetworkOperator()

Returns the numeric name (MCC+MNC) of current registered operator.

String getNetworkOperatorName()

Returns the alphabetic name of current registered operator.

int getNetworkType()
int getPhoneCount()

Returns the number of phones available.

int getPhoneType()

Returns a constant indicating the device phone type.

String getSimCountryIso()

Returns the ISO country code equivalent for the SIM provider's country code.

String getSimOperator()

Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM.

String getSimOperatorName()

Returns the Service Provider Name (SPN).

String getSimSerialNumber()

Returns the serial number of the SIM, if applicable.

int getSimState()

Returns a constant indicating the state of the default SIM card.

String getSubscriberId()

Returns the unique subscriber ID, for example, the IMSI for a GSM phone.

String getVoiceMailAlphaTag()

Retrieves the alphabetic identifier associated with the voice mail number.

String getVoiceMailNumber()

Returns the voice mail number.

int getVoiceNetworkType()

Returns the NETWORK_TYPE_xxxx for voice

Requires Permission: READ_PHONE_STATE

Uri getVoicemailRingtoneUri(PhoneAccountHandle accountHandle)

Returns the URI for the per-account voicemail ringtone set in Phone settings.

boolean hasCarrierPrivileges()

Has the calling application been granted carrier privileges by the carrier.

boolean hasIccCard()
boolean iccCloseLogicalChannel(int channel)

Closes a previously opened logical channel to the ICC card.

byte[] iccExchangeSimIO(int fileID, int command, int p1, int p2, int p3, String filePath)

Returns the response APDU for a command APDU sent through SIM_IO.

IccOpenLogicalChannelResponse iccOpenLogicalChannel(String AID)

Opens a logical channel to the ICC card.

String iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2, int p3, String data)

Transmit an APDU to the ICC card over the basic channel.

String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data)

Transmit an APDU to the ICC card over a logical channel.

boolean isHearingAidCompatibilitySupported()

Whether the phone supports hearing aid compatibility.

boolean isNetworkRoaming()

Returns true if the device is considered roaming on the current network, for GSM purposes.

boolean isSmsCapable()
boolean isTtyModeSupported()

Whether the phone supports TTY mode.

boolean isVoiceCapable()
boolean isVoicemailVibrationEnabled(PhoneAccountHandle accountHandle)

Returns whether vibration is set for voicemail notification in Phone settings.

boolean isWorldPhone()

Whether the device is a world phone.

void listen(PhoneStateListener listener, int events)

Registers a listener object to receive notification of changes in specified telephony states.

String sendEnvelopeWithStatus(String content)

Send ENVELOPE to the SIM and return the response.

boolean setLine1NumberForDisplay(String alphaTag, String number)

Set the line 1 phone number string and its alphatag for the current ICCID for display purpose only, for example, displayed in Phone Status.

boolean setOperatorBrandOverride(String brand)

Override the branding for the current ICCID.

boolean setPreferredNetworkTypeToGlobal()

Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA.

boolean setVoiceMailNumber(String alphaTag, String number)

Sets the voice mail number.

Inherited methods

From class java.lang.Object

Constants

ACTION_CONFIGURE_VOICEMAIL

Added in API level 23
String ACTION_CONFIGURE_VOICEMAIL

Open the voicemail settings activity to make changes to voicemail configuration.

Constant Value: "android.telephony.action.CONFIGURE_VOICEMAIL"

ACTION_PHONE_STATE_CHANGED

Added in API level 3
String ACTION_PHONE_STATE_CHANGED

Broadcast intent action indicating that the call state on the device has changed.

The EXTRA_STATE extra indicates the new call state. If the new state is RINGING, a second extra EXTRA_INCOMING_NUMBER provides the incoming phone number as a String.

Requires the READ_PHONE_STATE permission.

This was a sticky broadcast in version 1.0, but it is no longer sticky. Instead, use getCallState() to synchronously query the current call state.

See also:

Constant Value: "android.intent.action.PHONE_STATE"

ACTION_RESPOND_VIA_MESSAGE

Added in API level 18
String ACTION_RESPOND_VIA_MESSAGE

The Phone app sends this intent when a user opts to respond-via-message during an incoming call. By default, the device's default SMS app consumes this message and sends a text message to the caller. A third party app can also provide this functionality by consuming this Intent with a Service and sending the message using its own messaging system.

The intent contains a URI (available from getData()) describing the recipient, using either the sms:, smsto:, mms:, or mmsto: URI schema. Each of these URI schema carry the recipient information the same way: the path part of the URI contains the recipient's phone number or a comma-separated set of phone numbers if there are multiple recipients. For example, smsto:2065551234.

The intent may also contain extras for the message text (in EXTRA_TEXT) and a message subject (in EXTRA_SUBJECT).

Note: The intent-filter that consumes this Intent needs to be in a Service that requires the permission SEND_RESPOND_VIA_MESSAGE.

For example, the service that receives this intent can be declared in the manifest file with an intent filter like this:

 <!-- Service that delivers SMS messages received from the phone "quick response" -->
 <service android:name=".HeadlessSmsSendService"
          android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
          android:exported="true" >
   <intent-filter>
     <action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:scheme="sms" />
     <data android:scheme="smsto" />
     <data android:scheme="mms" />
     <data android:scheme="mmsto" />
   </intent-filter>
 </service>

Output: nothing.

Constant Value: "android.intent.action.RESPOND_VIA_MESSAGE"

APPTYPE_CSIM

Added in API level 24
int APPTYPE_CSIM

UICC application type is CSIM

Constant Value: 4 (0x00000004)

APPTYPE_ISIM

Added in API level 24
int APPTYPE_ISIM

UICC application type is ISIM

Constant Value: 5 (0x00000005)

APPTYPE_RUIM

Added in API level 24
int APPTYPE_RUIM

UICC application type is RUIM

Constant Value: 3 (0x00000003)

APPTYPE_SIM

Added in API level 24
int APPTYPE_SIM

UICC application type is SIM

Constant Value: 1 (0x00000001)

APPTYPE_USIM

Added in API level 24
int APPTYPE_USIM

UICC application type is USIM

Constant Value: 2 (0x00000002)

AUTHTYPE_EAP_AKA

Added in API level 24
int AUTHTYPE_EAP_AKA

Authentication type for UICC challenge is EAP AKA. See RFC 4187 for details.

Constant Value: 129 (0x00000081)

AUTHTYPE_EAP_SIM

Added in API level 24
int AUTHTYPE_EAP_SIM

Authentication type for UICC challenge is EAP SIM. See RFC 4186 for details.

Constant Value: 128 (0x00000080)

CALL_STATE_IDLE

Added in API level 1
int CALL_STATE_IDLE

Device call state: No activity.

Constant Value: 0 (0x00000000)

CALL_STATE_OFFHOOK

Added in API level 1
int CALL_STATE_OFFHOOK

Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.

Constant Value: 2 (0x00000002)

CALL_STATE_RINGING

Added in API level 1
int CALL_STATE_RINGING

Device call state: Ringing. A new call arrived and is ringing or waiting. In the latter case, another call is already active.

Constant Value: 1 (0x00000001)

DATA_ACTIVITY_DORMANT

Added in API level 4
int DATA_ACTIVITY_DORMANT

Data connection is active, but physical link is down

Constant Value: 4 (0x00000004)

DATA_ACTIVITY_IN

Added in API level 1
int DATA_ACTIVITY_IN

Data connection activity: Currently receiving IP PPP traffic.

Constant Value: 1 (0x00000001)

DATA_ACTIVITY_INOUT

Added in API level 1
int DATA_ACTIVITY_INOUT

Data connection activity: Currently both sending and receiving IP PPP traffic.

Constant Value: 3 (0x00000003)

DATA_ACTIVITY_NONE

Added in API level 1
int DATA_ACTIVITY_NONE

Data connection activity: No traffic.

Constant Value: 0 (0x00000000)

DATA_ACTIVITY_OUT

Added in API level 1
int DATA_ACTIVITY_OUT

Data connection activity: Currently sending IP PPP traffic.

Constant Value: 2 (0x00000002)

DATA_CONNECTED

Added in API level 1
int DATA_CONNECTED

Data connection state: Connected. IP traffic should be available.

Constant Value: 2 (0x00000002)

DATA_CONNECTING

Added in API level 1
int DATA_CONNECTING

Data connection state: Currently setting up a data connection.

Constant Value: 1 (0x00000001)

DATA_DISCONNECTED

Added in API level 1
int DATA_DISCONNECTED

Data connection state: Disconnected. IP traffic not available.

Constant Value: 0 (0x00000000)

DATA_SUSPENDED

Added in API level 1
int DATA_SUSPENDED

Data connection state: Suspended. The connection is up, but IP traffic is temporarily unavailable. For example, in a 2G network, data activity may be suspended when a voice call arrives.

Constant Value: 3 (0x00000003)

EXTRA_INCOMING_NUMBER

Added in API level 3
String EXTRA_INCOMING_NUMBER

The lookup key used with the ACTION_PHONE_STATE_CHANGED broadcast for a String containing the incoming phone number. Only valid when the new call state is RINGING.

Retrieve with getStringExtra(String).

Constant Value: "incoming_number"

EXTRA_STATE

Added in API level 3
String EXTRA_STATE

The lookup key used with the ACTION_PHONE_STATE_CHANGED broadcast for a String containing the new call state.

See also:

Constant Value: "state"

NETWORK_TYPE_1xRTT

Added in API level 4
int NETWORK_TYPE_1xRTT

Current network is 1xRTT

Constant Value: 7 (0x00000007)

NETWORK_TYPE_CDMA

Added in API level 4
int NETWORK_TYPE_CDMA

Current network is CDMA: Either IS95A or IS95B

Constant Value: 4 (0x00000004)

NETWORK_TYPE_EDGE

Added in API level 1
int NETWORK_TYPE_EDGE

Current network is EDGE

Constant Value: 2 (0x00000002)

NETWORK_TYPE_EHRPD

Added in API level 11
int NETWORK_TYPE_EHRPD

Current network is eHRPD

Constant Value: 14 (0x0000000e)

NETWORK_TYPE_EVDO_0

Added in API level 4
int NETWORK_TYPE_EVDO_0

Current network is EVDO revision 0

Constant Value: 5 (0x00000005)

NETWORK_TYPE_EVDO_A

Added in API level 4
int NETWORK_TYPE_EVDO_A

Current network is EVDO revision A

Constant Value: 6 (0x00000006)

NETWORK_TYPE_EVDO_B

Added in API level 9
int NETWORK_TYPE_EVDO_B

Current network is EVDO revision B

Constant Value: 12 (0x0000000c)

NETWORK_TYPE_GPRS

Added in API level 1
int NETWORK_TYPE_GPRS

Current network is GPRS

Constant Value: 1 (0x00000001)

NETWORK_TYPE_HSDPA

Added in API level 5
int NETWORK_TYPE_HSDPA

Current network is HSDPA

Constant Value: 8 (0x00000008)

NETWORK_TYPE_HSPA

Added in API level 5
int NETWORK_TYPE_HSPA

Current network is HSPA

Constant Value: 10 (0x0000000a)

NETWORK_TYPE_HSPAP

Added in API level 13
int NETWORK_TYPE_HSPAP

Current network is HSPA+

Constant Value: 15 (0x0000000f)

NETWORK_TYPE_HSUPA

Added in API level 5
int NETWORK_TYPE_HSUPA

Current network is HSUPA

Constant Value: 9 (0x00000009)

NETWORK_TYPE_IDEN

Added in API level 8
int NETWORK_TYPE_IDEN

Current network is iDen

Constant Value: 11 (0x0000000b)

NETWORK_TYPE_LTE

Added in API level 11
int NETWORK_TYPE_LTE

Current network is LTE

Constant Value: 13 (0x0000000d)

NETWORK_TYPE_UMTS

Added in API level 1
int NETWORK_TYPE_UMTS

Current network is UMTS

Constant Value: 3 (0x00000003)

NETWORK_TYPE_UNKNOWN

Added in API level 1
int NETWORK_TYPE_UNKNOWN

Network type is unknown

Constant Value: 0 (0x00000000)

PHONE_TYPE_CDMA

Added in API level 4
int PHONE_TYPE_CDMA

Phone radio is CDMA.

Constant Value: 2 (0x00000002)

PHONE_TYPE_GSM

Added in API level 1
int PHONE_TYPE_GSM

Phone radio is GSM.

Constant Value: 1 (0x00000001)

PHONE_TYPE_NONE

Added in API level 1
int PHONE_TYPE_NONE

No phone radio.

Constant Value: 0 (0x00000000)

PHONE_TYPE_SIP

Added in API level 11
int PHONE_TYPE_SIP

Phone is via SIP.

Constant Value: 3 (0x00000003)

SIM_STATE_ABSENT

Added in API level 1
int SIM_STATE_ABSENT

SIM card state: no SIM card is available in the device

Constant Value: 1 (0x00000001)

SIM_STATE_NETWORK_LOCKED

Added in API level 1
int SIM_STATE_NETWORK_LOCKED

SIM card state: Locked: requires a network PIN to unlock

Constant Value: 4 (0x00000004)

SIM_STATE_PIN_REQUIRED

Added in API level 1
int SIM_STATE_PIN_REQUIRED

SIM card state: Locked: requires the user's SIM PIN to unlock

Constant Value: 2 (0x00000002)

SIM_STATE_PUK_REQUIRED

Added in API level 1
int SIM_STATE_PUK_REQUIRED

SIM card state: Locked: requires the user's SIM PUK to unlock

Constant Value: 3 (0x00000003)

SIM_STATE_READY

Added in API level 1
int SIM_STATE_READY

SIM card state: Ready

Constant Value: 5 (0x00000005)

SIM_STATE_UNKNOWN

Added in API level 1
int SIM_STATE_UNKNOWN

SIM card state: Unknown. Signifies that the SIM is in transition between states. For example, when the user inputs the SIM pin under PIN_REQUIRED state, a query for sim status returns this state before turning to SIM_STATE_READY. These are the ordinal value of IccCardConstants.State.

Constant Value: 0 (0x00000000)

VVM_TYPE_CVVM

Added in API level 23
String VVM_TYPE_CVVM

A flavor of OMTP protocol with a different mobile originated (MO) format

Constant Value: "vvm_type_cvvm"

VVM_TYPE_OMTP

Added in API level 23
String VVM_TYPE_OMTP

The OMTP protocol.

Constant Value: "vvm_type_omtp"

Fields

EXTRA_STATE_IDLE

Added in API level 3
String EXTRA_STATE_IDLE

Value used with EXTRA_STATE corresponding to CALL_STATE_IDLE.

EXTRA_STATE_OFFHOOK

Added in API level 3
String EXTRA_STATE_OFFHOOK

Value used with EXTRA_STATE corresponding to CALL_STATE_OFFHOOK.

EXTRA_STATE_RINGING

Added in API level 3
String EXTRA_STATE_RINGING

Value used with EXTRA_STATE corresponding to CALL_STATE_RINGING.

Public methods

canChangeDtmfToneLength

Added in API level 23
boolean canChangeDtmfToneLength ()

Whether the device supports configuring the DTMF tone length.

Returns
boolean true if the DTMF tone length can be changed, and false otherwise.

createForSubscriptionId

Added in API level 24
TelephonyManager createForSubscriptionId (int subId)

Create a new TelephonyManager object pinned to the given subscription ID.

Parameters
subId int
Returns
TelephonyManager a TelephonyManager that uses the given subId for all calls.

getAllCellInfo

Added in API level 17
List<CellInfo> getAllCellInfo ()

Returns all observed cell information from all radios on the device including the primary and neighboring cells. Calling this method does not trigger a call to onCellInfoChanged(), or change the rate at which onCellInfoChanged() is called.

The list can include one or more CellInfoGsm, CellInfoCdma, CellInfoLte, and CellInfoWcdma objects, in any combination. On devices with multiple radios it is typical to see instances of one or more of any these in the list. In addition, zero, one, or more of the returned objects may be considered registered; that is, their CellInfo.isRegistered() methods may return true.

This method returns valid data for registered cells on devices with FEATURE_TELEPHONY.

This method is preferred over using getCellLocation(). However, for older devices, getAllCellInfo() may return null. In these cases, you should call getCellLocation() instead.

Requires permission: ACCESS_COARSE_LOCATION

Returns
List<CellInfo> List of CellInfo; null if cell information is unavailable.

getCallState

Added in API level 1
int getCallState ()

Returns one of the following constants that represents the current state of all phone calls. CALL_STATE_RINGING CALL_STATE_OFFHOOK CALL_STATE_IDLE

Returns
int

getCellLocation

Added in API level 1
CellLocation getCellLocation ()

Returns the current location of the device.

If there is only one radio in the device and that radio has an LTE connection, this method will return null. The implementation must not to try add LTE identifiers into the existing cdma/gsm classes.

In the future this call will be deprecated.

Returns
CellLocation Current location of the device or null if not available.

Requires Permission: ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION.

getDataActivity

Added in API level 1
int getDataActivity ()

Returns a constant indicating the type of activity on a data connection (cellular).

Returns
int

See also:

getDataState

Added in API level 1
int getDataState ()

Returns a constant indicating the current data connection state (cellular).

Returns
int

See also:

getDeviceId

Added in API level 1
String getDeviceId ()

Returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones. Return null if device ID is not available.

Requires Permission: READ_PHONE_STATE

Returns
String

getDeviceId

Added in API level 23
String getDeviceId (int slotId)

Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available.

Requires Permission: READ_PHONE_STATE

Parameters
slotId int: of which deviceID is returned
Returns
String

getDeviceSoftwareVersion

Added in API level 1
String getDeviceSoftwareVersion ()

Returns the software version number for the device, for example, the IMEI/SV for GSM phones. Return null if the software version is not available.

Requires Permission: READ_PHONE_STATE

Returns
String

getGroupIdLevel1

Added in API level 18
String getGroupIdLevel1 ()

Returns the Group Identifier Level1 for a GSM phone. Return null if it is unavailable.

Requires Permission: READ_PHONE_STATE

Returns
String

getIccAuthentication

Added in API level 24
String getIccAuthentication (int appType, 
                int authType, 
                String data)

Returns the response of authentication for the default subscription. Returns null if the authentication hasn't been successful

Requires that the calling app has carrier privileges or READ_PRIVILEGED_PHONE_STATE permission.

Parameters
appType int: the icc application type, like APPTYPE_USIM
authType int: the authentication type, AUTHTYPE_EAP_AKA or AUTHTYPE_EAP_SIM
data String: authentication challenge data, base64 encoded. See 3GPP TS 31.102 7.1.2 for more details.
Returns
String the response of authentication, or null if not available

See also:

getLine1Number

Added in API level 1
String getLine1Number ()

Returns the phone number string for line 1, for example, the MSISDN for a GSM phone. Return null if it is unavailable.

Requires Permission: READ_PHONE_STATE OR READ_SMS

The default SMS app can also use this.

Returns
String

getMmsUAProfUrl

Added in API level 19
String getMmsUAProfUrl ()

Returns the MMS user agent profile URL.

Returns
String

getMmsUserAgent

Added in API level 19
String getMmsUserAgent ()

Returns the MMS user agent.

Returns
String

getNeighboringCellInfo

Added in API level 3
List<NeighboringCellInfo> getNeighboringCellInfo ()

This method was deprecated in API level 23.
Use (@link getAllCellInfo} which returns a superset of the information from NeighboringCellInfo.

Returns the neighboring cell information of the device.

Returns
List<NeighboringCellInfo> List of NeighboringCellInfo or null if info unavailable.

Requires Permission: (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}

getNetworkCountryIso

Added in API level 1
String getNetworkCountryIso ()

Returns the ISO country code equivalent of the current registered operator's MCC (Mobile Country Code).

Availability: Only when user is registered to a network. Result may be unreliable on CDMA networks (use getPhoneType() to determine if on a CDMA network).

Returns
String

getNetworkOperator

Added in API level 1
String getNetworkOperator ()

Returns the numeric name (MCC+MNC) of current registered operator.

Availability: Only when user is registered to a network. Result may be unreliable on CDMA networks (use getPhoneType() to determine if on a CDMA network).

Returns
String

getNetworkOperatorName

Added in API level 1
String getNetworkOperatorName ()

Returns the alphabetic name of current registered operator.

Availability: Only when user is registered to a network. Result may be unreliable on CDMA networks (use getPhoneType() to determine if on a CDMA network).

Returns
String

getNetworkType

Added in API level 1
int getNetworkType ()

Returns
int the NETWORK_TYPE_xxxx for current data connection.

getPhoneCount

Added in API level 23
int getPhoneCount ()

Returns the number of phones available. Returns 0 if none of voice, sms, data is not supported Returns 1 for Single standby mode (Single SIM functionality) Returns 2 for Dual standby mode.(Dual SIM functionality)

Returns
int

getPhoneType

Added in API level 1
int getPhoneType ()

Returns a constant indicating the device phone type. This indicates the type of radio used to transmit voice calls.

Returns
int

See also:

getSimCountryIso

Added in API level 1
String getSimCountryIso ()

Returns the ISO country code equivalent for the SIM provider's country code.

Returns
String

getSimOperator

Added in API level 1
String getSimOperator ()

Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM. 5 or 6 decimal digits.

Availability: SIM state must be SIM_STATE_READY

Returns
String

See also:

getSimOperatorName

Added in API level 1
String getSimOperatorName ()

Returns the Service Provider Name (SPN).

Availability: SIM state must be SIM_STATE_READY

Returns
String

See also:

getSimSerialNumber

Added in API level 1
String getSimSerialNumber ()

Returns the serial number of the SIM, if applicable. Return null if it is unavailable.

Requires Permission: READ_PHONE_STATE

Returns
String

getSubscriberId

Added in API level 1
String getSubscriberId ()

Returns the unique subscriber ID, for example, the IMSI for a GSM phone. Return null if it is unavailable.

Requires Permission: READ_PHONE_STATE

Returns
String

getVoiceMailAlphaTag

Added in API level 1
String getVoiceMailAlphaTag ()

Retrieves the alphabetic identifier associated with the voice mail number.

Requires Permission: READ_PHONE_STATE

Returns
String

getVoiceMailNumber

Added in API level 1
String getVoiceMailNumber ()

Returns the voice mail number. Return null if it is unavailable.

Requires Permission: READ_PHONE_STATE

Returns
String

getVoiceNetworkType

Added in API level 24
int getVoiceNetworkType ()

Returns the NETWORK_TYPE_xxxx for voice

Requires Permission: READ_PHONE_STATE

Returns
int

getVoicemailRingtoneUri

Added in API level 24
Uri getVoicemailRingtoneUri (PhoneAccountHandle accountHandle)

Returns the URI for the per-account voicemail ringtone set in Phone settings.

Parameters
accountHandle PhoneAccountHandle: The handle for the PhoneAccount for which to retrieve the voicemail ringtone.
Returns
Uri The URI for the ringtone to play when receiving a voicemail from a specific PhoneAccount.

hasCarrierPrivileges

Added in API level 22
boolean hasCarrierPrivileges ()

Has the calling application been granted carrier privileges by the carrier. If any of the packages in the calling UID has carrier privileges, the call will return true. This access is granted by the owner of the UICC card and does not depend on the registered carrier.

Returns
boolean true if the app has carrier privileges.

hasIccCard

Added in API level 5
boolean hasIccCard ()

Returns
boolean true if a ICC card is present

iccCloseLogicalChannel

Added in API level 21
boolean iccCloseLogicalChannel (int channel)

Closes a previously opened logical channel to the ICC card. Input parameters equivalent to TS 27.007 AT+CCHC command.

Requires Permission: MODIFY_PHONE_STATE Or the calling app has carrier privileges. @see #hasCarrierPrivileges

Parameters
channel int: is the channel id to be closed as retruned by a successful iccOpenLogicalChannel.
Returns
boolean true if the channel was closed successfully.

iccExchangeSimIO

Added in API level 21
byte[] iccExchangeSimIO (int fileID, 
                int command, 
                int p1, 
                int p2, 
                int p3, 
                String filePath)

Returns the response APDU for a command APDU sent through SIM_IO.

Requires Permission: MODIFY_PHONE_STATE Or the calling app has carrier privileges. @see #hasCarrierPrivileges

Parameters
p1 int: P1 value of the APDU command.
p2 int: P2 value of the APDU command.
p3 int: P3 value of the APDU command.
Returns
byte[] The APDU response.

iccOpenLogicalChannel

Added in API level 21
IccOpenLogicalChannelResponse iccOpenLogicalChannel (String AID)

Opens a logical channel to the ICC card. Input parameters equivalent to TS 27.007 AT+CCHO command.

Requires Permission: MODIFY_PHONE_STATE Or the calling app has carrier privileges. @see #hasCarrierPrivileges

Parameters
AID String: Application id. See ETSI 102.221 and 101.220.
Returns
IccOpenLogicalChannelResponse an IccOpenLogicalChannelResponse object.

iccTransmitApduBasicChannel

Added in API level 21
String iccTransmitApduBasicChannel (int cla, 
                int instruction, 
                int p1, 
                int p2, 
                int p3, 
                String data)

Transmit an APDU to the ICC card over the basic channel. Input parameters equivalent to TS 27.007 AT+CSIM command.

Requires Permission: MODIFY_PHONE_STATE Or the calling app has carrier privileges. @see #hasCarrierPrivileges

Parameters
cla int: Class of the APDU command.
instruction int: Instruction of the APDU command.
p1 int: P1 value of the APDU command.
p2 int: P2 value of the APDU command.
p3 int: P3 value of the APDU command. If p3 is negative a 4 byte APDU is sent to the SIM.
data String: Data to be sent with the APDU.
Returns
String The APDU response from the ICC card with the status appended at the end.

iccTransmitApduLogicalChannel

Added in API level 21
String iccTransmitApduLogicalChannel (int channel, 
                int cla, 
                int instruction, 
                int p1, 
                int p2, 
                int p3, 
                String data)

Transmit an APDU to the ICC card over a logical channel. Input parameters equivalent to TS 27.007 AT+CGLA command.

Requires Permission: MODIFY_PHONE_STATE Or the calling app has carrier privileges. @see #hasCarrierPrivileges

Parameters
channel int: is the channel id to be closed as returned by a successful iccOpenLogicalChannel.
cla int: Class of the APDU command.
instruction int: Instruction of the APDU command.
p1 int: P1 value of the APDU command.
p2 int: P2 value of the APDU command.
p3 int: P3 value of the APDU command. If p3 is negative a 4 byte APDU is sent to the SIM.
data String: Data to be sent with the APDU.
Returns
String The APDU response from the ICC card with the status appended at the end.

isHearingAidCompatibilitySupported

Added in API level 23
boolean isHearingAidCompatibilitySupported ()

Whether the phone supports hearing aid compatibility.

Returns
boolean true if the device supports hearing aid compatibility, and false otherwise.

isNetworkRoaming

Added in API level 1
boolean isNetworkRoaming ()

Returns true if the device is considered roaming on the current network, for GSM purposes.

Availability: Only when user registered to a network.

Returns
boolean

isSmsCapable

Added in API level 21
boolean isSmsCapable ()

Returns
boolean true if the current device supports sms service.

If true, this means that the device supports both sending and receiving sms via the telephony network.

Note: Voicemail waiting sms, cell broadcasting sms, and MMS are disabled when device doesn't support sms.

isTtyModeSupported

Added in API level 23
boolean isTtyModeSupported ()

Whether the phone supports TTY mode.

Returns
boolean true if the device supports TTY mode, and false otherwise.

isVoiceCapable

Added in API level 22
boolean isVoiceCapable ()

Returns
boolean true if the current device is "voice capable".

"Voice capable" means that this device supports circuit-switched (i.e. voice) phone calls over the telephony network, and is allowed to display the in-call UI while a cellular voice call is active. This will be false on "data only" devices which can't make voice calls and don't support any in-call UI.

Note: the meaning of this flag is subtly different from the PackageManager.FEATURE_TELEPHONY system feature, which is available on any device with a telephony radio, even if the device is data-only.

isVoicemailVibrationEnabled

Added in API level 24
boolean isVoicemailVibrationEnabled (PhoneAccountHandle accountHandle)

Returns whether vibration is set for voicemail notification in Phone settings.

Parameters
accountHandle PhoneAccountHandle: The handle for the PhoneAccount for which to retrieve the voicemail vibration setting.
Returns
boolean true if the vibration is set for this PhoneAccount, false otherwise.

isWorldPhone

Added in API level 23
boolean isWorldPhone ()

Whether the device is a world phone.

Returns
boolean true if the device is a world phone, and false otherwise.

listen

Added in API level 1
void listen (PhoneStateListener listener, 
                int events)

Registers a listener object to receive notification of changes in specified telephony states.

To register a listener, pass a PhoneStateListener and specify at least one telephony state of interest in the events argument. At registration, and when a specified telephony state changes, the telephony manager invokes the appropriate callback method on the listener object and passes the current (updated) values.

To unregister a listener, pass the listener object and set the events argument to LISTEN_NONE (0).

Parameters
listener PhoneStateListener: The PhoneStateListener object to register (or unregister)
events int: The telephony state(s) of interest to the listener, as a bitwise-OR combination of PhoneStateListener LISTEN_ flags.

sendEnvelopeWithStatus

Added in API level 21
String sendEnvelopeWithStatus (String content)

Send ENVELOPE to the SIM and return the response.

Requires Permission: MODIFY_PHONE_STATE Or the calling app has carrier privileges. @see #hasCarrierPrivileges

Parameters
content String: String containing SAT/USAT response in hexadecimal format starting with command tag. See TS 102 223 for details.
Returns
String The APDU response from the ICC card in hexadecimal format with the last 4 bytes being the status word. If the command fails, returns an empty string.

setLine1NumberForDisplay

Added in API level 22
boolean setLine1NumberForDisplay (String alphaTag, 
                String number)

Set the line 1 phone number string and its alphatag for the current ICCID for display purpose only, for example, displayed in Phone Status. It won't change the actual MSISDN/MDN. To unset alphatag or number, pass in a null value.

Requires that the calling app has carrier privileges.

Parameters
alphaTag String: alpha-tagging of the dailing nubmer
number String: The dialing number
Returns
boolean true if the operation was executed correctly.

See also:

setOperatorBrandOverride

Added in API level 22
boolean setOperatorBrandOverride (String brand)

Override the branding for the current ICCID. Once set, whenever the SIM is present in the device, the service provider name (SPN) and the operator name will both be replaced by the brand value input. To unset the value, the same function should be called with a null brand value.

Requires that the calling app has carrier privileges.

Parameters
brand String: The brand name to display/set.
Returns
boolean true if the operation was executed correctly.

See also:

setPreferredNetworkTypeToGlobal

Added in API level 22
boolean setPreferredNetworkTypeToGlobal ()

Set the preferred network type to global mode which includes LTE, CDMA, EvDo and GSM/WCDMA.

Requires that the calling app has carrier privileges.

Returns
boolean true on success; false on any failure.

See also:

setVoiceMailNumber

Added in API level 22
boolean setVoiceMailNumber (String alphaTag, 
                String number)

Sets the voice mail number.

Requires that the calling app has carrier privileges.

Parameters
alphaTag String: The alpha tag to display.
number String: The voicemail number.
Returns
boolean

See also:

Hooray!