您的位置:首页 > 其它

手机IMSI码规则更新-通过IMSI判断运营商的方法

2020-06-24 14:51 316 查看

精选30+云产品,助力企业轻松上云!>>>

更新运营商判断规则:

中国移动系统使用00、02、04、07,中国联通GSM系统使用01、06、09,中国电信CDMA系统使用03、05、电信4G使用11,中国铁通系统使用20。

注意:getSimOperator方法不需要READ_PHONE_STATE权限

/**
* 返回手机运营商名称
* 中国移动系统使用00、02、04、07,中国联通GSM系统使用01、06、09,中国电信CDMA系统使用03、05、电信4G使用11,中国铁通系统使用20。*/
public void getMobileOperatorName() {
TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
//getSimOperator方法不需要READ_PHONE_STATE权限
String operator = telManager.getSimOperator();
Log.d(TAG, "operator:" + operator);
if (operator != null) {
if (operator.equals("46000") || operator.equals("46002") || operator.equals("46004") || operator.equals("46007")) {
//中国移动
Log.d(TAG, "中国移动");
} else if (operator.equals("46001") || operator.equals("46006") || operator.equals("46009")) {
//中国联通
Log.d(TAG, "中国联通");
} else if (operator.equals("46003") || operator.equals("46005") || operator.equals("46011")) {
//中国电信
Log.d(TAG, "中国电信");
} else if (operator.equals("46020")) {
Log.d(TAG, "中国铁通");
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: