當前位置:首頁 » 安卓系統 » 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 瀏覽:742
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:803
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:511
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:372