.tv做网站怎么样,网页制作与网站建设答案,精品课程网站开发环境,杭州做公司官网的公司2.2 非标识性参数
2.2.1 手机运营商
IMSI#xff1a; 国际移动用户识别码#xff0c;共有15位#xff0c;储存在SIM卡中#xff0c;由MCC、MNC#xff0c;MSIN组成。
MCC#xff1a; (国家)移动国家号码#xff0c;由3位数字组成#xff0c;唯一的识别移动客户所属的…2.2 非标识性参数
2.2.1 手机运营商
IMSI 国际移动用户识别码共有15位储存在SIM卡中由MCC、MNCMSIN组成。
MCC (国家)移动国家号码由3位数字组成唯一的识别移动客户所属的国家我国为460MNC (运营商)由两位数字组成用于识别移动客户所归属的移动网络。 中国移动系统使用00、02、04、07中国联通GSM系统使用01、06、09中国电信CDMA系统使用03、05、电信4G使用11 MSIN (个人)移动用户识别号码
所以想要知道运营商名称我们主要是通过判断MNC来区别是哪种运营商
2.2.1.1 获取方法
1.getSimOperator()、getSimOperatorName() 不需要任何权限
/**
不需要任何权限
getSimOperator()得到的是上网卡的运营商的MCCMNC
getSimOperatorName()得到的是拨号卡的运营商
**/public static String getSimOperatorName(Context context){String opeType OTHER;TelephonyManager telManager (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);int simState telManager.getSimState();if (simState ! TelephonyManager.SIM_STATE_READY) {String error null;switch (simState){case TelephonyManager.SIM_STATE_ABSENT:{//1error Sim 没有Sim卡;Log.i(Sim, 没有Sim卡);}case TelephonyManager.SIM_STATE_PIN_REQUIRED:{//2error Sim Sim卡状态锁定需要PIN解锁;Log.i(Sim, Sim卡状态锁定需要PIN解锁);}case TelephonyManager.SIM_STATE_PUK_REQUIRED:{//3error Sim Sim卡状态锁定需要PUK解锁;Log.i(Sim ,Sim卡状态锁定需要PUK解锁);}case TelephonyManager.SIM_STATE_NETWORK_LOCKED:{//4error Sim 需要网络PIN码解锁;Log.i(Sim, 需要网络PIN码解锁);}//...}return error;}String simOperator telManager.getSimOperator();String simOperatorName telManager.getSimOperatorName();Log.i(Sim,getSimOperator()获取的MCCMNC为:simOperator);Log.i(Sim, getSimOperatorName()方法获取的运营商名称为:simOperatorName);Log.i(Sim,(simOperator460002) opeType);if (46001.equals(simOperator) || 46006.equals(simOperator) || 46009.equals(simOperator)) {opeType 中国联通;} else if (46000.equals(simOperator) || 46002.equals(simOperator) || 46004.equals(simOperator) || 46007.equals(simOperator)) {opeType 中国移动;Log.i(Sim,opeType);} else if (46003.equals(simOperator) || 46005.equals(simOperator) || 46011.equals(simOperator)) {opeType 中国电信;} else if (46020.equals(simOperator)) {opeType 中国铁通;} else {opeType OHTER;}Log.i(Sim, 通过getSimOperator()人为判断的运营商名称是: opeType);return 通过getSimOperator()人为判断的运营商名称是: opeType getSimOperatorName()方法获取的运营商名称为:simOperatorName;}2 getNetWorkOperator()、getNetworkOperatorName() 不需要权限
/**
不需要权限
getNetWorkOperator()得到的是拨号卡的运营商MCCMNC
getNetworkOperatorName()得到的是拨号卡的运营商
**/
public static String getNetWorkOperatorName(Context context) {String opeType OTHER;TelephonyManager telManager (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);//用于判断拨号那张卡的运营商int phoneType telManager.getPhoneType();if (phoneType TelephonyManager.PHONE_TYPE_CDMA) {Log.i(Sim, getNetWorkOperatorNameTest: 在CDMA网络上不可靠所以不用这种方法);return getNetWorkOperatorNameTest: 在CDMA网络上不可靠所以不用这种方法;}switch (phoneType){case 0:{Log.i(Sim, getPhoneType()网络类型为NO_PHONE);}case 1:{Log.i(Sim, getPhoneType()网络类型为GSM_PHONE);}case 2:{Log.i(Sim, getPhoneType()网络类型为CDMA_PHONE);}case 3:{Log.i(Sim, getPhoneType()网络类型为SIP_PHONE);}case 4:{Log.i(Sim, getPhoneType()网络类型为THIRD_PARTY_PHONE);}case 5:{Log.i(Sim, getPhoneType()网络类型为IMS_PHONE);}case 6:{Log.i(Sim, getPhoneType()网络类型为CDMA_LTE_PHONE);}}String networkOperator telManager.getNetworkOperator();String networkOperatorName telManager.getNetworkOperatorName();Log.i(Sim, getNetWorkOperator()获取的MCCMNC为: networkOperator);Log.i(Sim, getNetworkOperatorName()方法获取的网络类型名称是: networkOperatorName);if (46001.equals(networkOperator) || 46006.equals(networkOperator) || 46009.equals(networkOperator)) {opeType 中国联通;} else if (46000.equals(networkOperator) || 46002.equals(networkOperator) || 46004.equals(networkOperator) || 46007.equals(networkOperator)) {opeType 中国移动;} else if (46003.equals(networkOperator) || 46005.equals(networkOperator) || 46011.equals(networkOperator)) {opeType 中国电信;} else {opeType OHTER;}Log.i(Sim, 通过getNetWorkOperator()人为判断的运营商名称是: opeType);return 通过getNetWorkOperator()人为判断的运营商名称是: opeType getNetworkOperatorName()方法获取的网络类型名称是: networkOperatorName;}
2.2.1.2 获取方法总结 getSimOperator()得到上网卡运营商 getSimOperatorName()、getNetworkOperator()、getNetworkOperatorName()得到拨号卡运营商 问题一 如果想得到运营商名称可直接用getSimOperatorName()或者getNetworkOperatorName()就能直接获取到。为什么还要用getNetworkOperator()通过MNC号来人为的判断 因为在有些手机上获取到的名称是CMCC、CUCC、CTCC而不是中国移动、中国联通、中国电信所以需要我们人为的判断。
参考链接
手机运营商https://blog.csdn.net/Myfittinglife/article/details/118685804