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).
Note that acess 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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_PHONE_STATE_CHANGED | Broadcast intent action indicating that the call state (cellular) on the device has changed. | |||||||||
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_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. | |||||||||
String | EXTRA_STATE_IDLE | Value used with EXTRA_STATE corresponding to CALL_STATE_IDLE. | |||||||||
String | EXTRA_STATE_OFFHOOK | Value used with EXTRA_STATE corresponding to CALL_STATE_OFFHOOK. | |||||||||
String | EXTRA_STATE_RINGING | Value used with EXTRA_STATE corresponding to CALL_STATE_RINGING. | |||||||||
int | NETWORK_TYPE_EDGE | Current network is EDGE | |||||||||
int | NETWORK_TYPE_GPRS | Current network is GPRS | |||||||||
int | NETWORK_TYPE_UMTS | Current network is UMTS | |||||||||
int | NETWORK_TYPE_UNKNOWN | Network type is unknown | |||||||||
int | PHONE_TYPE_GSM | GSM phone | |||||||||
int | PHONE_TYPE_NONE | No phone module | |||||||||
int | SIM_STATE_ABSENT | SIM card state: no SIM card is available in the device | |||||||||
int | SIM_STATE_NETWORK_LOCKED | SIM card state: Locked: requries 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. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a constant indicating the call state (cellular) on the device.
| |||||||||||
Returns the current location of the device.
| |||||||||||
Returns a constant indicating the type of activity on a data connection
(cellular).
| |||||||||||
Returns a constant indicating the current data connection state
(cellular).
| |||||||||||
Returns the unique device ID, for example,the IMEI for GSM
phones.
| |||||||||||
Returns the software version number for the device, for example,
the IMEI/SV for GSM phones.
| |||||||||||
Returns the phone number string for line 1, for example, the MSISDN
for a GSM phone.
| |||||||||||
Returns the neighboring cell information of the device.
| |||||||||||
Returns the ISO country code equivilent of the current registered
operator's MCC (Mobile Country Code).
| |||||||||||
Returns the numeric name (MCC+MNC) of current registered operator.
| |||||||||||
Returns the alphabetic name of current registered operator.
| |||||||||||
Returns a constant indicating the radio technology (network type)
currently in use on the device.
| |||||||||||
Returns a constant indicating the device phone type.
| |||||||||||
Returns the ISO country code equivalent for the SIM provider's country code.
| |||||||||||
Returns the MCC+MNC (mobile country code + mobile network code) of the
provider of the SIM.
| |||||||||||
Returns the Service Provider Name (SPN).
| |||||||||||
Returns the serial number of the SIM, if applicable.
| |||||||||||
Returns a constant indicating the state of the
device SIM card.
| |||||||||||
Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
| |||||||||||
Retrieves the alphabetic identifier associated with the voice
mail number.
| |||||||||||
Returns the voice mail number.
| |||||||||||
Returns true if the device is considered roaming on the current
network, for GSM purposes.
| |||||||||||
Registers a listener object to receive notification of changes
in specified telephony states.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Broadcast intent action indicating that the call state (cellular) 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.
Device call state: No activity.
Device call state: Off-hook. At least one call exists that is dialing, active, or on hold, and no calls are ringing or waiting.
Device call state: Ringing. A new call arrived and is ringing or waiting. In the latter case, another call is already active.
Data connection activity: Currently receiving IP PPP traffic.
Data connection activity: Currently both sending and receiving IP PPP traffic.
Data connection activity: No traffic.
Data connection activity: Currently sending IP PPP traffic.
Data connection state: Connected. IP traffic should be available.
Data connection state: Currently setting up a data connection.
Data connection state: Disconnected. IP traffic not available.
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.
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).
The lookup key used with the ACTION_PHONE_STATE_CHANGED broadcast for a String containing the new call state.
Value used with EXTRA_STATE corresponding to CALL_STATE_IDLE.
Value used with EXTRA_STATE corresponding to CALL_STATE_OFFHOOK.
Value used with EXTRA_STATE corresponding to CALL_STATE_RINGING.
Current network is EDGE
Current network is GPRS
Current network is UMTS
Network type is unknown
GSM phone
No phone module
SIM card state: no SIM card is available in the device
SIM card state: Locked: requries a network PIN to unlock
SIM card state: Locked: requires the user's SIM PIN to unlock
SIM card state: Locked: requires the user's SIM PUK to unlock
SIM card state: Ready
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.
Returns a constant indicating the call state (cellular) on the device.
Returns the current location of the device.
Requires Permission: ACCESS_COARSE_LOCATION.
Returns a constant indicating the type of activity on a data connection (cellular).
Returns a constant indicating the current data connection state (cellular).
Returns the unique device ID, for example,the IMEI for GSM phones.
Requires Permission: READ_PHONE_STATE
Returns the software version number for the device, for example, the IMEI/SV for GSM phones.
Requires Permission: READ_PHONE_STATE
Returns the phone number string for line 1, for example, the MSISDN for a GSM phone.
Requires Permission: READ_PHONE_STATE
Returns the neighboring cell information of the device.
Requires Permission: (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
Returns the ISO country code equivilent of the current registered operator's MCC (Mobile Country Code).
Availability: Only when user is registered to a network
Returns the numeric name (MCC+MNC) of current registered operator.
Availability: Only when user is registered to a network
Returns the alphabetic name of current registered operator.
Availability: Only when user is registered to a network
Returns a constant indicating the radio technology (network type) currently in use on the device.
Returns a constant indicating the device phone type.
Returns the ISO country code equivalent for the SIM provider's country code.
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 the Service Provider Name (SPN).
Availability: SIM state must be SIM_STATE_READY
Returns the serial number of the SIM, if applicable.
Requires Permission: READ_PHONE_STATE
Returns a constant indicating the state of the device SIM card.
Returns the unique subscriber ID, for example, the IMSI for a GSM phone.
Requires Permission: READ_PHONE_STATE
Retrieves the alphabetic identifier associated with the voice mail number.
Requires Permission: READ_PHONE_STATE
Returns the voice mail number.
Requires Permission: READ_PHONE_STATE
Returns true if the device is considered roaming on the current network, for GSM purposes.
Availability: Only when user registered to a network
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 (udpated) values.
To unregister a listener, pass the listener object and set the events argument to LISTEN_NONE (0).
listener | The PhoneStateListener object to register (or unregister) |
---|---|
events | The telephony state(s) of interest to the listener, as a bitwise-OR combination of PhoneStateListener LISTEN_ flags. |