android 移动国家代码,Android-imsi-MCC-MNC-国家码

本文介绍了Android中如何获取和解析IMSI中的MCC(移动国家码)和MNC(移动网络码),并提供了相关代码示例。MCC用于识别移动用户所属的国家,中国的MCC为460;MNC则标识网络运营商。通过MCC,可以进一步获取对应的ISO国家代码和电话区号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

Android获取MccTable

使用

/**

* 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";

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值