[英]How to get dual sim IMEI no in Android
我必須在我的Android手機上找到雙重SIM卡號碼。 我在許多網站上進行了檢查,發現我必須使用getdeviceid(0) or getdeviceid(1)
但其無法正常工作。 它顯示錯誤
該代碼是
TelephonyManager telephonyManager =
(TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
String imei = telephonyManager.getDeviceId(0);
String imei1 = telephonyManager.getDeviceId(1);
我已經附上了屏幕截圖。 請檢查並回復我
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String m1PhoneNumber = tMgr.getLine1Number();
String m2PhoneNumber = tMgr.getLine2Number();
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
它僅在API級別22及更高版本中有效
if (android.os.Build.VERSION.SDK_INT >= 22) {
try {
TelephonyManager telephonyManager = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
SubscriptionManager subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
int Count = subscriptionManager.getActiveSubscriptionInfoCount();
if (telephonyManager != null) {
if (Count > 1) {
if (android.os.Build.VERSION.SDK_INT >= 22) {
SIM1 = telephonyManager.getDeviceId(0);
SIM2 = telephonyManager.getDeviceId(1);
if (!SIM1.equalsIgnoreCase("") && !SIM2.equalsIgnoreCase("")) {
isDualSIM = true;
}
}
}else{
// single sim
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.