当前位置:首页 » 安卓系统 » androidmcc

androidmcc

发布时间: 2023-05-12 19:22:24

A. 智能手机网络运营商怎么设置

一、以苹果XR的ios13系统为例,点击【设置】,如下图所示:

B. android开发中怎么获取当前位置的坐标

GPS 精准但是慢,Android原生的
基站定位 手机到至少三个基站的位置来进行定位,原理是信号的衰减。 需要基站的所有位置信息,即需要服务器支持
AGPS 对GPS的一种方式,基站定位配合GPS,实现快速定位。
第三方定位,网络定位、高德定位等,根据其提供的SDK实现

C. 安卓双卡双待导致获取不到mcc

1. 存储在SIM卡中的mcc/mnc

这个值是存储在SIM卡IMSI(国际移动用户识别码 International Mobile Subscriber Identification Number)中的固定值,不会被更改。有以下两种途径可以取得。

1.1 通过TelephonyManager获得

在TelephonyManager中有如下方法:

//TelephonyManager.java

/**

* Returns the MCC+MNC (mobile country code + mobile network code) of the
* provider of the SIM for a particular subscription. 5 or 6 decimal digits.

*

* Availability: SIM state must be {@link #SIM_STATE_READY}

*

* @see #getSimState

*

* @param subId for which SimOperator is returned

* @hide

*/

public String getSimOperatorNumeric(int subId) {

int phoneId = SubscriptionManager.getPhoneId(subId);

return getSimOperatorNumericForPhone(phoneId);

}

/**

* Returns the MCC+MNC (mobile country code + mobile network code) of the

* provider of the SIM for a particular subscription. 5 or 6 decimal digits.

*

*

* @param phoneId for which SimOperator is returned

* @hide

*/

public String getSimOperatorNumericForPhone(int phoneId) {

return getTelephonyProperty(phoneId,

TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");

}

↓↓↓

由于subId并不固定,是根据放进sim卡槽时候的计数来统计的,但是如果相关类中有SubscriptionInfo对象的话,是可以直接取到的:

int subId = mSubscriptionInfo.getSubscriptionId();

另一种phoneId则比较简单了,它与sim卡数量有关,单卡时为0,双卡时根据sim slot位置分别取0和1。

1.2 通过SubscriptionInfo获得

在有些特殊情况下,比如SIM卡处于PIN码LOCK状态时,1.1所提到的方法是取不到的,这个时候只能通过SubscriptionInfo来取。

// SubscriptionInfo.java

/**

* @return the MCC.

*/

public int getMcc() {

return this.mMcc;

}

/**

* @return the MNC.

*/

public int getMnc() {

return this.mMnc;

}

注意,由于这个方法取到的mcc/mnc均为int值,比如中国联通的“46001”,则有mcc为“460”,mnc为“1”,与固定String字符串进行匹配比对的亏州话,需要先将String拆分为两部分后分别强转成int型链尺后才销唤蔽可进行比对。

2. SIM卡注册网络的mcc/mnc

非漫游情况下,注册网络的mcc/mnc就是SIM卡中存储的。但是如果你的SIM卡在其他国家并没有该运营商的基站,只能通过漫游到其他运营商的网络上维持服务时,注册网络的mcc/mnc对应的就是该运营商的值,与SIM卡无关了。

2.1 通过ServiceState获得

熟悉Android Telephony流程的朋友应该都知道,CS、PS域的注册状态,漫游状态,运营商名字的显示,网络模式等都是用模板类ServiceState.java来保存的。

SystemUI中有不少类都注册了PhoneStateListener这个callback,用来时刻关注设备的一些telephony相关状态,当网络服务状态有变化时,会回调其onServiceStateChanged(ServiceState serviceState)方法,这样我们就可以直接从ServiceState里面取了。

// ServiceState.java

/**

* Get current registered operator numeric id.

*

* In GSM/UMTS, numeric format is 3 digit country code plus 2 or 3 digit

* network code.

*

* @return numeric format of operator, null if unregistered or unknown

*/

/*

* The country code can be decoded using

* {@link com.android.internal.telephony.MccTable#countryCodeForMcc(int)}.

*/

public String getOperatorNumeric() {

return mVoiceOperatorNumeric;

}

/**

* Get current registered voice network operator numeric id.

* @return numeric format of operator, null if unregistered or unknown

* @hide

*/

public String getVoiceOperatorNumeric() {

return mVoiceOperatorNumeric;

}

/**

* Get current registered data network operator numeric id.

* @return numeric format of operator, null if unregistered or unknown

* @hide

*/

public String getDataOperatorNumeric() {

return mDataOperatorNumeric;

}

一般来说,voice语音业务和data数据业务对应的OperatorNumeric是一样的,所以getOperatorNumeric()默认取了voice的。

2.2 通过监听Telephony广播获得

由于该Intent action为MTK新增的,故以下方法介绍均以MTK源码为基础。

上面的方法必须在voice与data均注册成功的前提下才能获得,但是在一些很特殊的环境下,比如SIM卡虽然漫游上了某个其他运营商的网络,但由于两家运营商之间并没有协议,导致无法注册上服务,此时voice和data取得的OperatorNumeric均为空的。

在MTK源码中,MtkServiceStateTracker在处理PLMN String即mcc/mnc时,会通过action为“TelephonyIntents.ACTION_LOCATED_PLMN_CHANGED”的广播,把它作为extra参数传递出去。

// MtkServiceStateTracker.java

private void updateLocatedPlmn(String plmn) {

if (((mLocatedPlmn == null) && (plmn != null)) ||

((mLocatedPlmn != null) && (plmn == null)) ||

((mLocatedPlmn != null) && (plmn != null) && !(mLocatedPlmn.equals(plmn)))) {

log("updateLocatedPlmn(),previous plmn= " + mLocatedPlmn + " ,update to: " + plmn);

Intent intent = new Intent(TelephonyIntents.ACTION_LOCATED_PLMN_CHANGED);

if (TelephonyManager.getDefault().getPhoneCount() == 1) {

intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);

}

intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);

...

mPhone.getContext().sendStickyBroadcastAsUser(intent, UserHandle.ALL);

}

mLocatedPlmn = plmn;

}

由此可知,只要在需要取的类中,注册一个监听“ACTION_LOCATED_PLMN_CHANGED”的BroadcastReceiver就行了,在设备开机之后便可以第一时间拿到漫游网络的mcc/mnc值,具体如下:

private BroadcastReceiver mReceiver = new BroadcastReceiver() {

@Override

public void onReceive(Context context, Intent intent) {

final String action = intent.getAction();

if (action.equals(TelephonyIntents.ACTION_LOCATED_PLMN_CHANGED)) {

mLocatedPlmn = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);

// mLocatedPlmn即为漫游网络的mcc/mnc值,接下来用它操作即可

D. Android 判断SIM卡属于哪个移动运营商

第一种方法:
获取手机的IMSI码,并判断是中国移动\中国联通\中国电信
TelephonyManager telManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
/** 获取SIM卡的IMSI码
* SIM卡唯一标识:IMSI 国际移动用户识别码(IMSI:InternationalMobile Subscriber Identification Number)是区别移动用户的标志,
* 储存在SIM卡中,可用于区别移动用户的有效信息。IMSI由MCC、MNC、MSIN组成,其中MCC为移动国家号码,由3位数字组成,
*唯一地识别移动客户所属的国家,我国为460;MNC为网络id,由2位数字组成,
*用于识别移动客户所归属的移动网络,中国移动为00,中国联通为01,中国电信为03;MSIN为移动客户识别码,采用等长11位数字构成。
* 唯一地识别国内GSM移动通信网中移动客户。所以要区分是移动还是联通,只需取得SIM卡中的MNC字段即可
*/
Stringimsi = telManager.getSubscriberId();
if(imsi!=null){
if(imsi.startsWith("46000") ||imsi.startsWith("46002")){//因为移动网络编号46000下的IMSI已经用完,所以虚拟了一个46002编号,134/159号段使用了此编号
//中国移动
}elseif(imsi.startsWith("46001")){
//中国联通
}elseif(imsi.startsWith("46003")){
//中国电信
}
}

第二种方法
TelephonyManager telManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
Stringoperator = telManager.getSimOperator();
if(operator!=null){
if(operator.equals("46000") ||operator.equals("46002")){
//中国移动
}elseif(operator.equals("46001")){
//中国联通
}elseif(operator.equals("46003")){
//中国电信
}
}

E. 安卓手机中网络参数有哪些,mcc,mnc是什么意思

mcc 是国家编码亏磨:中国是 460
mnc是销辩斗运营商编码:移动灶灶 是 0 联通是 1 电信是2

热点内容
内置存储卡可以拆吗 发布:2025-05-18 04:16:35 浏览:336
编译原理课时设置 发布:2025-05-18 04:13:28 浏览:378
linux中进入ip地址服务器 发布:2025-05-18 04:11:21 浏览:612
java用什么软件写 发布:2025-05-18 03:56:19 浏览:32
linux配置vim编译c 发布:2025-05-18 03:55:07 浏览:107
砸百鬼脚本 发布:2025-05-18 03:53:34 浏览:944
安卓手机如何拍视频和苹果一样 发布:2025-05-18 03:40:47 浏览:741
为什么安卓手机连不上苹果7热点 发布:2025-05-18 03:40:13 浏览:803
网卡访问 发布:2025-05-18 03:35:04 浏览:511
接收和发送服务器地址 发布:2025-05-18 03:33:48 浏览:372