Telephonymanager Category: Acquisition of Android phone and SIM card status

Source: Internet
Author: User

Telephonymanager This class is useful and can get a lot of information about mobile phones and SIM cards.
Directly on the code after the comment, please enjoy

Package Net.sunniwell.app;
Import android.app.Activity;
Import Android.os.Bundle;
Import android.telephony.CellLocation;
Import Android.telephony.PhoneStateListener;
Import Android.telephony.TelephonyManager;
public class Telmanager extends Activity {

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Telephonymanager TM = (Telephonymanager) this.getsystemservice (Telephony_service);

/*
* Phone Status:
* 1.tm. Call_state_idle=0 No Activity
* 2.tm. Call_state_ringing=1 Bells
* 3.tm. Call_state_offhook=2 Pick-up machine
*/
tm.getcallstate ();//int

  /*
* Phone Directions:
*/
tm.getcelllocation ();//celllocation

/*
* Unique Device ID:
* GSM phone's IMEI and CDMA phone MEID.
* Return NULL if device ID is not available.
*/
Tm.getdeviceid (); //string

  /*
* Software version number of the device:
* For example: The IMEI/SV (software version) for GSM phones.
* Return NULL if the software version is not available.
*/
tm.getdevicesoftwareversion ();//string

/*
* Phone Number:
* GSM mobile phone's MSISDN.
* Return NULL if it is unavailable.
*/
Tm.getline1number (); //string

/*
* Nearby Telephone information:
* Type:list<neighboringcellinfo>
* Requires permission: Android. Manifest.permission#access_coarse_updates
*/
tm.getneighboringcellinfo ();//list<neighboringcellinfo>

/*
* Get the ISO Standard country code, which is the international long distance code.
* Note: Only if the user has been registered with the network.
* Results may not be reliable in CDMA networks.
*/
Tm.getnetworkcountryiso ();//string

  /*
* MCC+MNC (Mobile Country code + mobile network Code)
* Note: Only if the user is already active on the network registration.
* Results may not be reliable in CDMA networks.
*/
tm.getnetworkoperator (); //string

/*
* Name of current registered operator (currently registered user) in alphabetical order
* Note: Only if the user is already active on the network registration.
* Results may not be reliable in CDMA networks.
*/
tm.getnetworkoperatorname ();//string

/*
* The type of network currently in use:
* Example: Network_type_unknown network type unknown 0
* Network_type_gprs GPRS Network 1
* Network_type_edge EDGE Network 2
* NETWORK_TYPE_UMTS UMTS Network 3
* NETWORK_TYPE_HSDPA HSDPA Network 8
* Network_type_hsupa HSUPA Network 9
* Network_type_hspa HSPA Network 10
* NETWORK_TYPE_CDMA CDMA Network, is95a or is95b. 4
* NETWORK_TYPE_EVDO_0 EVDO Network, Revision 0. 5
* Network_type_evdo_a EVDO Network, revision A. 6
* Network_type_1xrtt 1xRTT Network 7
*/
Tm.getnetworktype ();//int

  /*
* Phone Type:
* For example: Phone_type_none no signal
* PHONE_TYPE_GSM GSM Signal
* PHONE_TYPE_CDMA CDMA Signal
*/
Tm.getphonetype ();//int

  /*
* Returns the ISO Country code equivalent for the SIM provider ' s country code.
* Obtain the ISO country code, which is equivalent to providing a SIM card country code.
*/
Tm.getsimcountryiso ();//string

/*
* Returns the MCC+MNC (mobile Country code + mobile Network Code) of the provider of the SIM. 5 or 6 decimal digits.
* Get the Mobile country Code and mobile network code provided by the SIM card. 5 or 6-bit decimal digits.
* The status of the SIM card must be Sim_state_ready (use Getsimstate () to determine).
*/
tm.getsimoperator ();//string

  /*
* Name of service provider:
* For example: China Mobile, Unicom
* The status of the SIM card must be Sim_state_ready (use Getsimstate () to determine).
*/
tm.getsimoperatorname ();//string

/*
* Serial number of SIM card:
* Requires permission: read_phone_state
*/
Tm.getsimserialnumber ();//string

/*
* Status information of SIM:
* Sim_state_unknown Unknown State 0
* Sim_state_absent Card 1
* sim_state_pin_required lock status, requires the user PIN code to unlock 2
* sim_state_puk_required lock status, requires the user's PUK code unlock 3
* sim_state_network_locked lock status, need network PIN code unlock 4
* Sim_state_ready Ready State 5
*/
tm.getsimstate ();//int

/*
* Unique User id:
* For example: IMSI (International Mobile User ID) for a GSM phone.
* Requires permission: read_phone_state
*/
Tm.getsubscriberid ();//string

  /*
* Gets the label associated with the voice mail, which is the identifier
* Requires permission: read_phone_state
*/
Tm.getvoicemailalphatag (); //string

  /*
* Get voice mail number:
* Requires permission: read_phone_state
*/
Tm.getvoicemailnumber ();//string

  /*
* The ICC card is present
*/
Tm.hasicccard (); //boolean

  /*
* Whether to roam:
* (under GSM use)
*/
tm.isnetworkroaming ();//

}
}

Telephonymanager Category: Acquisition of Android phone and SIM card status

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.