An example analysis of Telephonymanager class in Android _android

Source: Internet
Author: User

The examples in this article describe the methods of Telephonymanager classes in Android. Share to everyone for your reference. Specifically as follows:

The Telephonymanager class mainly provides a series of get methods for accessing state and information related to mobile communications. This includes the status and information of Mobile SIM, the status of telecom network and the information of mobile phone users. You can use these get methods in your application to obtain related data.

The object of the Telephonymanager class can be obtained by the Context.getsystemservice (Context.telephony_service) method, and it should be noted that some communication information is restricted to the permission of the application. , you need to add the appropriate permissions to it when you develop it.

All methods and descriptions for 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 to Phone status * * Call_state_idle without any state * Call_state_offhook pick up the phone when the phone comes in call_state_ringing
    * * Tm.getcallstate ();
    Returns the position of the current mobile Terminal celllocation location=tm.getcelllocation ();
    Request location Update, if the update will produce 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: activity, receiving data * data_activity_Out data Connection Status: activity, sending data * data_activity_inout data Connection Status: Activity, receiving and sending data * Data_activity_none data Connection Status: Activity, but no data to send and accept * *
    Tm.getdataactivity (); /** * Get Data Connection Status * * data_connected data Connection Status: Connected * data_connecting data connection Status: Connecting * data_disconnected number
    According to the connection status: Disconnect * data_suspended data Connection Status: Suspend/Tm.getdatastate ();
    /** * Returns the unique identifier of the current mobile terminal * If it is a GSM network, return IMEI; if it is a CDMA network, return MEID * * Tm.getdeviceid ();
    Return to the mobile terminal software version, for example: GSM mobile phone IMEI/SV code.
    Tm.getdevicesoftwareversion ();
    Return mobile phone number, for GSM network namely MSISDN Tm.getline1number ();
    Returns the information list<neighboringcellinfo> Infos=tm.getneighboringcellinfo () of the mobile terminal near the current mobile terminal;
      for (Neighboringcellinfo Info:infos) {//Get the Neighbor cell number int cid=info.getcid (); Get neighbor Cell Lac,lac: Location area code.
      In order to determine the location of the mobile station, the coverage area of each GSM/PLMN is divided into many location areas, and LAC is used to identify different location areas.
      Info.getlac ();
      Info.getnetworktype ();
      INFO.GETPSC ();
    Obtain signal intensity Info.getrssi () of neighboring cell; //Return to the ISO standard country code, that is, the international long-distance code tm.getnetWorkcountryiso ();
    Return MCC+MNC code (SIM card carrier country code and operator 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 for UMTS or HSDPA, mobile and Unicom 2G for GPRS or EGDE, telecom 2G for CDMA, telecom 3G for EVDO * * Tm.getnetworktype (); /** * Return 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_no
    NE mobile phone format unknown/tm.getphonetype ();
    Returns the SIM card provider's country code tm.getsimcountryiso ();
    Return MCC+MNC code (SIM card carrier country code and operator Network Code) (IMSI) tm.getsimoperator ();
    Tm.getsimoperatorname ();
    Returns the SIM card serial number (IMEI) tm.getsimserialnumber (); /** * Move backMobile Terminal * * * sim_state_absent SIM card not found * sim_state_network_locked SIM card Network is locked and requires network PIN unlock * sim_state_pin
     The _required SIM card PIN is locked and requires a user pin unlock * sim_state_puk_required SIM card PUK is locked and requires user PUK unlock * sim_state_ready SIM card available
    * Sim_state_unknown SIM Card Unknown/tm.getsimstate ();
    Returns the unique identification of the user, such as the IMSI number of the GSM network Tm.getsubscriberid (); 
    Gets the letter ID associated with the voice mail number.
    Tm.getvoicemailalphatag ();
    Return the voice mail number Tm.getvoicemailnumber ();
    Tm.hasicccard ();
    Returns whether the mobile phone is in a roaming state tm.isnetworkroaming ();
    Tm.listen (Phonestatelistener Listener, int events); Explanation://imsi is the International Mobile User identification code abbreviation (International Mobile subscriber Identity)//imsi A total of 15 digits, its structure is as follows://mcc+mnc+min//MCC
    : Mobile Country code, moving country code, a total of 3, China for 460; Mnc:mobile Networkcode, mobile network Code, a total of 2 bits//In China, the mobile code for 00 and 02, Unicom's Code is 01, the Telecom Code is 03//Combined is (also the Android phone in the APN configuration file Code)://China Mobile: 46000 46002//China Unicom: 46001//Telecom: 46003//For example, a typical IMSI number for 460030912121001//imei is International mobile equi PmeNT identity (International Mobile device identification) abbreviation//IMEI consists of 15 digits of the "electronic string number", which corresponds to each cell phone one by one, and the code is the world's only//its composition is://1. The first 6 digits (TAC) is the "Model approval number" and is generally representative of the model//2. The next 2 digits (FAC) is the "final assembly number", the general representative of Origin//3. After the 6 digits (SNR) is "serial number", the general representative of the production sequence number//4. The last 1 digits (SP) is usually "0″, for inspection code, current temporary}}"

I hope this article will help you with your Android program.

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.