IMEI号是GSM的概念,CDMA对应的是MEID号。
IMEI获取
private TelephonyManager telMgr;
telMgr = TelephonyManager.from(mContext);
imei_0 = telMgr.getImei(1);
MEID获取
public String GetPhoneInfo(int slotId) {
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Class clazz = telephonyManager.getClass();
Method getMeid = null;
try {
getMeid = clazz.getDeclaredMethod("getMeid", int.class);//(int slotId)
system_meid = (String) getMeid.invoke(telephonyManager, slotId); //sim_1
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
Throwable t = e.getTargetException();
t.printStackTrace();
}
return system_meid;
}