Android obtains carrier Information

Source: Internet
Author: User

Android obtains carrier Information

After receiving a new request to send the device carrier name to the server, my first response was that umeng was unable to accurately count the operator. How can I determine the specific carrier to send the request? For example:


This token reflects the names of the operators that umeng collects statistics on users' mobile phones. Is there any way to accurately determine the specific operator? For example, only China Mobile, China Unicom, and China Telecom are returned ".
The solution here is to identify by the MCC/MNC code of the device.
First, read the Wikipedia for what MCC/MNC is. After reading this article, we can know what carriers we need to know by comparing the MCC/MNC codes.
Second, the specific code is as follows:

/*** The return carrier requires the permission to join
  
   
** @ Return 1, representing China Mobile, 2, representing China Unicom, 3, representing China Telecom, 0, representing unknown * @ author youzc@yiche.com */public int getOperators (Context context) {// Mobile device Network Code (MNC) is the same as the Mobile Country Code (MCC) (also known as "MCC // MNC ") combined, for example, 46000, the first three are MCC, and the last two are MNC to obtain the mobile phone service provider Information int OperatorsName = 0; String IMSI = (TelephonyManager) context. getSystemService (Context. TELEPHONY_SERVICE ). getSubscriberId (); // The first 3 digits of the IMSI number are countries, followed by the code of the second 00 operator System. out. println (IMSI); if (IMSI. startsWith ("46000") | IMSI. startsWith ("46002") | IMSI. startsWith ("46007") {OperatorsName = 1;} else if (IMSI. startsWith ("46001") | IMSI. startsWith ("46006") {OperatorsName = 2;} else if (IMSI. startsWith ("46003") | IMSI. startsWith ("46005") {OperatorsName = 3;} return OperatorsName ;}
  

I disagree with this method by comparing the local client with MCC/MNC to determine the carrier. I think it is the best solution to send the MCC/MNC to the server. The code is dead because the application pack is distributed out, and the comparison cannot be expanded in the future, but the server can be dynamic and the MCC/MNC encoding can be configured at any time.

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.