Android obtains carrier Information

Source: Internet
Author: User

Android obtains carrier Information

The project requires a three-network release product. The three single-network sdks are automatically integrated into the three networks. The idea is probably to divide the SDK into operators in the OnCreate time zone.

Set enumeration, assign enumeration variables based on the obtained SIM card information, and perform subsequent operations on the three networks based on enumeration.


Set carrier enumeration first

enum CARRIEROPERATOR{NONE(0),MM(1),UNIPAY(2),EGAME(3);private int value;    private CARRIEROPERATOR(int i)    {        this.value=i;    }         public int getValue()    {        return this.value;    }}CARRIEROPERATOR carrierOperator = CARRIEROPERATOR.NONE;



Which carrier is the SIM card?

Public int getSimOperatorInfo () {TelephonyManager telephonyManager = (TelephonyManager) getSystemService (Context. TELEPHONY_SERVICE); String operatorString = telephonyManager. getSimOperator (); if (operatorString = null) {return 0;} if (operatorString. equals ("46000") | operatorString. equals ("46002") {// China Mobile return 1;} else if (operatorString. equals ("46001") {// China Unicom return 2;} else if (operatorString. equals ("46003") {// China Telecom return 3;} // errorreturn 0 ;}

Call the following function in the onCreate function to set the carrier

void SetCarrierOperation(){int simCode = GetSimOperatorInfo();switch(simCode){case 0:carrierOperator = CARRIEROPERATOR.NONE;break;case 1:carrierOperator = CARRIEROPERATOR.MM;break;case 2:carrierOperator = CARRIEROPERATOR.UNIPAY;break;case 3:carrierOperator = CARRIEROPERATOR.EGAME;break;default:Log.e("unity","SetCarrierOperation error");break;}}

Original article, reprinted please note

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.