Telephonymanager: Android phone and SIM card status acquisition

Source: Internet
Author: User
Reprint Address: http://blog.csdn.net/sunxingzhesunjinbiao/article/details/7021328
AndroidAcquisition of the local number and SIM card status

Telephonymanager This class is useful and can get a lot of information about mobile phones and SIM cards.
Immediately after the comment code, 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 Bell
* 3.tm. Call_state_offhook=2 Picking Machine
*/
tm.getcallstate ();Int

/*
* Phone Location:
*/
tm.getcelllocation ();Celllocation

/*
* Unique Device ID:
* GSM mobile phone IMEI and CDMA mobile phone MEID.
* Return NULL if Device ID isn't 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 are not available.
*/
tm.getdevicesoftwareversion ();String

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

/*
* Information about the telephone nearby:
* Type:list<neighboringcellinfo>
* Need permission:Android. Manifest.permission#access_coarse_updates
*/
tm.getneighboringcellinfo ();List<neighboringcellinfo>

/*
* Obtain the ISO standard country code, namely the international long-distance code.
* Note: Only if the user has been registered with the network.
* Results may be unreliable in CDMA networks.
*/
Tm.getnetworkcountryiso ();String

/*
* MCC+MNC (Mobile Country code + mobile network Code)
* Note: Valid only if the user is already registered on the network.
* Results may be unreliable in CDMA networks.
*/
tm.getnetworkoperator ();String

/*
* Name of current registered operator (currently registered user) in alphabetical order
* Note: Valid only if the user is already registered on the network.
* Results may be unreliable in CDMA networks.
*/
tm.getnetworkoperatorname ();String

/*
* The type of network currently in use:
* For 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

/*
* Mobile 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 the 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. 5 or 6 decimal digits provided by the SIM card.
* The status of the SIM card must be Sim_state_ready (usinggetsimstate() judgment).
*/
tm.getsimoperator ();String

/*
* Service Provider Name:
* For example: China Mobile, Unicom
* The status of the SIM card must be Sim_state_ready (usinggetsimstate() judgment).
*/
tm.getsimoperatorname ();String

/*
* The serial number of the SIM card:
* Need permission: Read_phone_state
*/
Tm.getsimserialnumber ();String

/*
* Status information for SIM:
* Sim_state_unknown Unknown State 0
* Sim_state_absent No card 1
* sim_state_pin_required lock status, requires user's PIN code unlock 2
* sim_state_puk_required lock state, requires the user's PUK code unlock 3
* sim_state_network_locked lock status, require network PIN unlock 4
* Sim_state_ready Ready Status 5
*/
TM. getsimstate ();Int

/*
* Unique User id:
* For example: IMSI (International Mobile User identification Code) for a GSM phone.
* Need permission: Read_phone_state
*/
Tm.getsubscriberid ();String

/*
* Get the label associated with the voice mail, that is, the identifier
* Need permission: Read_phone_state
*/
Tm.getvoicemailalphatag ();String

/*
* Get voice mail number:
* Need permission: Read_phone_state
*/
Tm.getvoicemailnumber ();String

/*
* Whether the ICC card exists
*/
Tm.hasicccard ();Boolean

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

}
}

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.