我必须在我的Android手机上找到双sim imei号码。我在许多网站上查了一下我发现我必须使用href
但它不起作用。它显示错误
代码是
getdeviceid(0) or getdeviceid(1)
我已附上截图。请检查并回复我
答案 0 :(得分:0)
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"/>
答案 1 :(得分:0)
仅适用于 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();
}
}