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

更新运营商判断规则:

中国移动系统使用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, "中国铁通");
            }
        }
    }

猜你喜欢

转载自blog.csdn.net/fanwei4751/article/details/106896446
今日推荐