[英]How to get dual sim IMEI no in Android
I have to find dual sim imei number on my android phone . 我必须在我的Android手机上找到双重SIM卡号码。 I have check on many website I found that I have to use
getdeviceid(0) or getdeviceid(1)
But its not working . 我在许多网站上进行了检查,发现我必须使用
getdeviceid(0) or getdeviceid(1)
但其无法正常工作。 It showing the error 它显示错误
The code is 该代码是
TelephonyManager telephonyManager =
(TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
String imei = telephonyManager.getDeviceId(0);
String imei1 = telephonyManager.getDeviceId(1);
I have attached the screenshot . 我已经附上了屏幕截图。 Kindly check it and reply me
请检查并回复我
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"/>
its only worked in API Level 22 and above 它仅在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.