Home>

The telephonymanager class mainly provides a series of get methods for accessing the status and information related to mobile phone communication. This includes the status and information of the mobile phone sim, the status of the telecommunications network, and the information of the mobile phone user.You can use these get methods in your application to get the relevant data.

Objects of the telephonymanager class can be obtained by the context.getsystemservice (context.telephony_service) method.It should be noted that the acquisition of some communication information has certain restrictions on the permissions of the application.When developing, you need to add corresponding permissions.

The following lists all methods and descriptions of the telephonymanager class:

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);
    /**
     * Back to phone status
     *
     * call_state_idle when there is no state
     * call_state_offhook when answering a call
     * call_state_ringing when the call comes in
     * /
    tm.getcallstate ();
    //Return the current mobile terminal position
    celllocation location=tm.getcelllocation ();
    //request position update,If the update will produce a broadcast,The receiving object is an object registered for listen_cell_location, and the required permission name is 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:active, but no data is sent and received
     * /
    tm.getdataactivity ();
    /**
     * Get data connection status
     *
     * data_connected data connection status:connected
     * data_connecting data connection status:connecting
     * data_disconnected data connection status:disconnected
     * data_suspended data connection status:suspended
     * /
    tm.getdatastate ();
    /**
     * Returns the unique identifier of the current mobile terminal
     *
     * If it is gsm network, return imei;if it is cdma network, return meid
     * /
    tm.getdeviceid ();
    //return the software version of the mobile terminal,For example:imei/sv code of gsm mobile phone.
    tm.getdevicesoftwareversion ();
    //return mobile number,For gsm networks it is msisdn
    tm.getline1number ();
    //Return information of mobile terminals 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 position of the mobile station,The coverage area of ​​each gsm/plmn is divided into many location areas,lac is used to identify different location areas.
      info.getlac ();
      info.getnetworktype ();
      info.getpsc ();
      //Get signal strength of neighbor cell
      info.getrssi ();
    }
    //return the country code of iso standard,Area code
    tm.getnetworkcountryiso ();
    //return mcc+ mnc code (sim card operator country code and operator network code) (imsi)
    tm.getnetworkoperator ();
    //Return the name of the mobile network operator (spn)
    tm.getnetworkoperatorname ();
    /**
     * Get network type
     *
     * network_type_cdma The network type is cdma
     * network_type_edge network type is edge
     * network_type_evdo_0 The 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, 3g of China Unicom is umts or hsdpa, 2g of China Mobile and China Unicom is gprs or egde, 2g of China Telecom is cdma, 3g of China Telecom is evdo
     * /
    tm.getnetworktype ();
    /**
     * Returns the type of mobile terminal
     *
     * phone_type_cdma The phone format is cdma, telecommunications
     * phone_type_gsm mobile phone format is gsm
     * phone_type_none Unknown phone format
     * /
    tm.getphonetype ();
    //Return the country code of the sim card provider
    tm.getsimcountryiso ();
    //return mcc+ mnc code (sim card operator country code and operator network code) (imsi)
    tm.getsimoperator ();
    tm.getsimoperatorname ();
    //Return the serial number of the sim card (imei)
    tm.getsimserialnumber ();
    /**
     * Back to mobile terminal
     *
     * sim_state_absent sim card not found
     * sim_state_network_locked sim card network is locked,Need network pin to unlock
     * sim_state_pin_required sim card pin is locked, user pin needs to be unlocked
     * sim_state_puk_required sim card puk is locked and needs user puk to unlock
     * sim_state_ready sim card is available
     * sim_state_unknown
     * /
    tm.getsimstate ();
    //return the user unique ID,Such as the imsi number of the gsm network
    tm.getsubscriberid ();
    //Get the letter ID associated with the voicemail number.
    tm.getvoicemailalphatag ();
    //Return voice mail number
    tm.getvoicemailnumber ();
    tm.hasicccard ();
    //Returns whether the phone is roaming
    tm.isnetworkroaming ();
    //tm.listen (phonestatelistener listener, int events);
    //Explanation:
    //imsi is short for international mobile subscriber identity
    //imsi has a total of 15 bits, and its structure is as follows:
    //mcc+ mnc+ min
    //mcc:mobile country code,3 in total, 460 in China;
    //mnc:mobile networkcode,Total 2
    //In China, the code for mobile is 00 and 02, the code for China Unicom is 01, and the code for China Telecom is 03
    //Together it is (also the code in the apn configuration file in the android 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
    //imei consists of 15-digit "electronic serial number", which corresponds to each mobile phone one by one,And the code is the only one in the world.
    //Its composition is:
    //1. The first 6 digits (tac) is the "model approval number", which generally represents the model
    //2. The next two digits (fac) is the "last 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 digit (sp) is usually "0", which is the check code.
Currently on standby
  }
}
  • Previous Use regular expression NSRegularExpression in iOS to validate textfiled input
  • Next jQuery Easyui verify that two passwords are entered equal