Android 如何从双 SIM 卡手机获取两个 IMEI 号码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11880881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get both IMEI numbers from dual SIM mobile?
提问by VenkaReddy
How can I get both IMEI numbers from dual SIM mobile? Can anyone help me to resolve this problem.
如何从双 SIM 卡手机获取两个 IMEI 号码?谁能帮我解决这个问题。
回答by Kishore
Any information regarding SIM #2 (or any other then default SIM) is purely manufacturer dependent. Android does not provide APIs for multi-SIM facility. Android apis only support default SIM Card slot. You can contact Micromax (device manufacturer) if he can provide you apis to support his hardware component.
任何有关 SIM #2(或任何其他默认 SIM)的信息完全取决于制造商。Android 不提供用于多 SIM 卡设施的 API。Android apis 仅支持默认 SIM 卡插槽。您可以联系 Micromax(设备制造商),如果他可以为您提供 api 来支持他的硬件组件。
回答by chandan kumar
You can try the following code it will help you.
您可以尝试以下代码,它将帮助您。
TelephonyManager manager= (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
try {
Class<?> telephonyClass = Class.forName(manager.getClass().getName());
Class<?>[] parameter = new Class[1];
parameter[0] = int.class;
Method getFirstMethod = telephonyClass.getMethod("getDeviceId", parameter);
Log.d("SimData", getFirstMethod.toString());
Object[] obParameter = new Object[1];
obParameter[0] = 0;
String first = (String) getFirstMethod.invoke(manager, obParameter);
Log.d("IMEI ", "first :" + first);
obParameter[0] = 1;
String second = (String) getFirstMethod.invoke(manager, obParameter);
Log.d("IMEI ", "Second :" + second);
} catch (Exception e) {
e.printStackTrace();
}
And add the permission on menifest.
并在menifest上添加权限。
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>