Android_ get a variety of details about your phone

Source: Internet
Author: User

The Telephonymanager class provides a series of get methods for accessing status and information related to mobile communication. These include mobile SIM status and information, the status of the telecommunications network, and the information of mobile phone users. You can use these get methods in your application to get related data.

Objects of the Telephonymanager class can be obtained by means of the Context.getsystemservice (Context.telephony_service) method, and it is important to note that the acquisition of some communication information has certain limitations on the permissions of the application. , you need to add the appropriate permissions for the development.

All methods and descriptions of the Telephonymanager class are listed below:

Package com.ljq.activity;

Import java.util.List;

Import Android.app.Activity;
Import Android.content.Context;
Import Android.os.Bundle;
Import Android.telephony.CellLocation;
Import Android.telephony.NeighboringCellInfo;
Import Android.telephony.TelephonyManager;

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 phone status
*
* Call_state_idle is not in any state
* When Call_state_offhook pick up the phone
* Call_state_ringing When the phone comes in
*/
Tm.getcallstate ();
Returns the location of the current mobile terminal
Celllocation location=tm.getcelllocation ();
Request location Update, if the update will generate a broadcast, the receiving object is a registered Listen_cell_location object, the permission name required is called 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 sent and accepted
*/
Tm.getdataactivity ();
/**
* Get Data Connection Status
*
* Data_connected Data Connection Status: connected
* Data_connecting Data connection Status: Connecting
* Data_disconnected Data Connection Status: Disconnect
* Data_suspended Data Connection Status: Paused
*/
Tm.getdatastate ();
/**
* Returns the unique identity of the current mobile terminal
*
* If it is a GSM network, return the IMEI; if it is a CDMA network, return Meid
*/
Tm.getdeviceid ();
Returns the software version of the mobile terminal, for example: GSM phone IMEI/SV code.
Tm.getdevicesoftwareversion ();
Return mobile phone number, for GSM network is MSISDN
Tm.getline1number ();
Returns information about the mobile terminal near the current mobile terminal
List<neighboringcellinfo> Infos=tm.getneighboringcellinfo ();
for (Neighboringcellinfo Info:infos) {
Get Neighbor Cell number
int Cid=info.getcid ();
Get neighbor Cell Lac,lac: Location area code. To determine the location of the mobile station, each GSM/PLMN coverage is divided into a number of location areas, and the LAC is used to identify different locations.
Info.getlac ();
Info.getnetworktype ();
INFO.GETPSC ();
Get neighbor Cell signal strength
Info.getrssi ();
}
Returns the ISO standard country code, which is the international calling code
Tm.getnetworkcountryiso ();
Return MCC+MNC code (SIM card carrier country code and carrier Network Code) (IMSI)
Tm.getnetworkoperator ();
Returns the name of the mobile network operator (SPN)
Tm.getnetworkoperatorname ();
/**
* Get network type
*
* NETWORK_TYPE_CDMA network type is CDMA
* Network_type_edge network type is EDGE
* Network_type_evdo_0 network type is EVDO0
* Network_type_evdo_a network type is EVDOA
* Network_type_gprs network type is GPRS
* NETWORK_TYPE_HSDPA network type is HSDPA
* Network_type_hspa network type is HSPA
* Network_type_hsupa network type is HSUPA
* Network_type_umts network type is UMTS
*
* In China, Unicom's 3G is UMTS or HSDPA, mobile and Unicom 2G for GPRS or EGDE, telecom 2G for CDMA, telecom 3G for EVDO
*/
Tm.getnetworktype ();
/**
* Returns the type of mobile terminal
*
* PHONE_TYPE_CDMA mobile phone format for CDMA, telecommunications
* PHONE_TYPE_GSM mobile phone format for GSM, Mobile and Unicom
* Phone_type_none Phone format unknown
*/
Tm.getphonetype ();
Return the country code of the SIM card provider
Tm.getsimcountryiso ();
Return MCC+MNC code (SIM card carrier country code and carrier Network Code) (IMSI)
Tm.getsimoperator ();
Tm.getsimoperatorname ();
Returns the serial number (IMEI) of the SIM card
Tm.getsimserialnumber ();
/**
* Back to Mobile terminal
*
* Sim_state_absent SIM Card not found
* sim_state_network_locked SIM Card Network is locked and needs to be unlocked
* sim_state_pin_required SIM card PIN is locked and user pin is required to unlock
* sim_state_puk_required SIM card PUK is locked and requires user PUK to unlock
* Sim_state_ready SIM Card available
* Sim_state_unknown SIM Card Unknown
*/
Tm.getsimstate ();
Returns the user's unique identifier, such as the IMSI number of the GSM network
Tm.getsubscriberid ();
Gets the letter ID associated with the voicemail number.
Tm.getvoicemailalphatag ();
return voice mail number
Tm.getvoicemailnumber ();
Tm.hasicccard ();
Returns whether the phone is in a roaming state
Tm.isnetworkroaming ();
Tm.listen (Phonestatelistener Listener, int events);

Explain:
IMSI is the abbreviation for the International Mobile Subscriber Identification Code (International Mobile Subscriber Identity)
IMSI a total of 15 bits, the structure is as follows:
Mcc+mnc+min
Mcc:mobile Country Code, mobile country Code, a total of 3 people, China is 460;
Mnc:mobile Networkcode, mobile network code, total 2 bits
In China, the code for Mobile is 00 and 02, the code for Unicom is 01, and the code for telecommunications is 03.
The combination is (also the code in the APN configuration file on the Android phone):
China Mobile: 46000 46002
China Unicom: 46001
China Telecom: 46003
For example, a typical IMSI number is 460030912121001.

IMEI is the abbreviation for International Mobile Equipment identity (International mobile device identity)
The IMEI consists of a 15-digit "E-string", which corresponds to one by one of each phone, and the code is the only one in the world
Its composition is:
1. The first 6 digits (TAC) is the "Model approval number", the general representative of the model
2. The next 2-digit number (FAC) is the "final assembly number", which generally represents the origin
3. The next 6 digits (SNR) is the "serial number", which generally represents the production sequence number
4. The last 1 digits (SP) are usually "0″, for the verification code, the current standby
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.