The telephonymanager class provides a series of get methods for accessing the status and information related to mobile communication. The information includes the status and information of the mobile phone SIM, the status of the Telecom Network, and the information of the mobile phone user. In applications, you can use these get methods to obtain relevant data.
Objects of the telephonymanager class can use context. getsystemservice (context. telephony_service) method to obtain, it is worth noting that some communication information acquisition has certain restrictions on the permissions of the application, you need to add the corresponding permissions during development.
<Uses-Permission Android: Name = "android. Permission. read_phone_state"/>
All methods and descriptions of the telephonymanager class are listed as follows:
Public class telephonymanageractivity extends activity {
@ Override
Public void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. Main );
Telephonymanager TM = (telephonymanager) getsystemservice (context. telephony_service );
/**
* Return the phone number status
*
* When call_state_idle is not in any status
* When call_state_offhook calls
* When call_state_ringing calls in
*/
TM. getcallstate ();
// Return the current mobile terminal location
Celllocation location = TM. getcelllocation ();
// Request location update. If the update generates a broadcast, the receiving object is the object registered with listen_cell_location. The permission name is access_coarse_location.
Location. requestlocationupdate ();
/**
* Get data Activity Status
*
* Data_activity_in data connection status: active, receiving data
* Data_activity_out data connection status: active, sending data
* Data_activity_inout data connection status: active, receiving and sending data
* Data_activity_none data connection status: active, but no data is sent or accepted
*/
TM. getdataactivity ();
/**
* Obtain the data connection status
*
* Data_connected data connection status: connected
* Data_connecting data connection status: Connecting
* Data_disconnected data connection status: disconnected
* Data_suincluded data connection status: paused
*/
TM. getdatastate ();
/**
* Return the unique identifier of the current mobile terminal.
*
* If it is a GSM network, IMEI is returned; if it is a CDMA network, meId is returned.
*/
TM. getdeviceid ();
// Return the software version of the mobile terminal, for example, the IMEI/SV code of the GSM mobile phone.
TM. getdevicesoftwareversion ();
// Return the mobile phone number, which is msisdn for the GSM network.
TM. getline1number ();
// Return the information of the mobile terminal near the current mobile terminal
List <neighboringcellinfo> Infos = TM. getneighboringcellinfo ();
For (neighboringcellinfo info: Infos ){
// Obtain the neighbor code
Int cid = info. getcid ();
// Obtain the LAC and LAC of the neighboring zone: the location zone domain code. To determine the location of the Mobile Station, each GSM/plmn coverage area is divided into many location areas, and the LAC is used to identify different location areas.
Info. getlac ();
Info. getnetworktype ();
Info. getpsc ();
// Obtain the signal strength of the neighbor cell
Info. getarg ();
}
// Return the ISO Standard Country Code, that is, the international long-distance area code.
TM. getnetworkcountryiso ();
// Return the MCC + MNC code (Country Code of the SIM card carrier and network code of the carrier) (imsi)
TM. getnetworkoperator ();
// Return the name of the mobile network operator (SPNs)
TM. getnetworkoperatorname ();
/**
* Obtain the network type
*
* Network_type_cdma: The network type is CDMA.
* Network_type_edge: The network type is edge.
* Network_type_evdo_0 the network type is evdo0
* Network_type_evdo_a network type is evdoa.
* Network_type_gprs: The network type is GPRS.
* Network_type_hsdpa: The network type is HSDPA.
* Network_type_hspa: The network type is HSPA.
* Network_type_hsupa: The network type is hsupa.
* The network_type_umts network type is UMTS.
*
* China Unicom's 3G network is UMTS or HSDPA, China Mobile and China Unicom's 2G network is GPRS or egde, China Telecom's 2G network is CDMA, and China Telecom's 3G network is evdo.
*/
TM. getnetworktype ();
/**
* Return the mobile terminal type
*
* The phone_type_cdma mobile phone system is CDMA and telecom
* The phone_type_gsm mobile phone system is GSM, mobile and Unicom
* The Phone System of phone_type_none is unknown.
*/
TM. getphonetype ();
// Return the country code of the SIM card provider
TM. getsimcountryiso ();
// Return the MCC + MNC code (Country Code of the SIM card carrier and network code of the carrier) (imsi)
TM. getsimoperator ();
TM. getsimoperatorname ();
// Return the serial number of the SIM card (IMEI)
TM. getsimserialnumber ();
/**
* Return to Mobile Terminal
*
* Sim_state_absent SIM card not found
* The Network of the sim_state_network_locked SIM card is locked and must be unlocked by a network pin.
* The sim_state_pin_required SIM card pin is locked and must be unlocked by the user pin.
* The sim_state_puk_required SIM card Puk is locked and must be unlocked by the user Puk.
* Sim_state_ready SIM card available
* The sim_state_unknown SIM card is unknown.
*/
TM. getsimstate ();
// Return the Unique User ID, such as the imsi ID of the GSM network.
TM. getsubscriberid ();
// Obtain the letter ID associated with the voicemail number.
TM. getvoicemailalphatag ();
// Return the voice mail number
TM. getvoicemailnumber ();
TM. hasicccard ();
// Returns whether the mobile phone is roaming.
TM. isnetworkroaming ();
// TM. Listen (phonestatelistener listener, int events );
// Explanation:
// Imsi (short for International Mobile Subscriber Identity)
// Imsi has a total of 15 digits. Its structure is as follows:
// MCC + MNC + min
// MCC: Mobile country code, mobile country code, 3 in total, 460 in China;
// MNC: Mobile networkcode, mobile network code, two digits in total
// In China, the mobile code is e 00 and 02, China Unicom code is 01, and China Telecom code is 03
// The combination is (also the code in the APN configuration file of the Android mobile phone ):
// China Mobile: 46000 46002
// China Unicom 46001
// China Telecom 46003
// For example, a typical imsi number is 460030912121001.
// IMEI is short for International Mobile Equipment Identity (international mobile device identification)
// IMEI is an electronic string consisting of 15 digits. It corresponds to each mobile phone one by one and is the only one in the world.
// Its composition is:
// 1. The first 6 digits (TAC) are "model approval numbers", which generally represent models
// 2. The next two digits (FAC) are the "last Assembly number", which generally represents the origin
// 3. The next 6 digits (SNR) are "string numbers", which generally represent the production sequence numbers
// 4. The last 1-digit (SP) is usually "0", which is the Verification Code and is currently in use.
}
}