title: Android-imsi-MCC-MNC-国家码
date: 2019-11-17 18:40:50
categories:
- Country Code
tags:
- MCC&MNC
mcc和mnc概述
mcc和mnc见 MCC(移动国家码)和 MNC(移动网络码)
MCC:Mobile Country Code,移动国家码,MCC的资源由国际电联(ITU)统一分配和管理,唯一识别移动用户所属的国家,共3位,中国为460;
MNC:Mobile Network Code,移动网络码,共2位,中国移动TD系统使用00,中国联通GSM系统使用01,中国移动GSM系统使用02,中国电信CDMA系统使用03
https://github.com/musalbas/mcc-mnc-table/
https://blog.csdn.net/firedancer0089/article/details/60954782
Android获取MccTable
http://androidxref.com/9.0.0_r3/xref/frameworks/opt/telephony/src/java/com/android/internal/telephony/MccTable.java
http://androidxref.com/9.0.0_r3/xref/frameworks/opt/telephony/tests/telephonytests/src/com/android/internal/telephony/MccTableTest.java
使用
/**
* Given a GSM Mobile Country Code, returns
* an ISO two-character country code if available.
* Returns "" if unavailable.
*/
public static String isoForMcc(int mcc) {
MccEntry entry = entryForMcc(mcc);
if (entry == null) {
return "";
} else {
return entry.mIso;
}
}
/**
* Given a GSM Mobile Country Code, returns
* an ISO two-character country code if available.
* Returns "" if unavailable.
*/
public static String countryCodeForMcc(int mcc) {
MccEntry entry = entryForMcc(mcc);
if (entry == null) {
return "";
} else {
return entry.mIso;
}
}
public static String getPhoneCode(String imsi) {
if (!TextUtils.isEmpty(imsi)) {
try {
int mcc = Integer.valueOf(imsi.substring(0, 3));
String countryIos = MccTable.isoForMcc(mcc);
CCPCountry cCPCountry = CCPCountry.getCountryForNameCodeFromLibraryMasterList(SimboxApp.instance, CountryCodePicker.Language.CHINESE_SIMPLIFIED, countryIos);
return cCPCountry.getPhoneCode();
} catch (Exception e) {
e.printStackTrace();
}
}
return "-1";
}
网友评论