Reputation: 41
I am using below code to get the IMEI of the Android devices,
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
IMEI = tm.getDeviceId();
It is fine for the devices having a single sim active. If we apply the same code for the devices having two sim cards, then how can I get the DeviceID
and tell whether I got SIM1 Id or SIM2 Id?
Upvotes: 1
Views: 11360
Reputation: 11337
IMEI number should be associated with the phone and not with the sim, so also in dual sim devices you should have only one IMEI number.
"The IMEI is only used for identifying the device" [...] "Instead, the subscriber is identified by transmission of an IMSI number, which is stored on a SIM card" - ref: Wikipedia
EDIT:
Check the source code, maybe you can find some hint: Source of Settings app
Here a snippet of the "IMEI" part:
// NOTE "imei" is the "Device ID" since it represents
// the IMEI in GSM and the MEID in CDMA
if (mPhone.getPhoneName().equals("CDMA")) {
setSummaryText(KEY_MEID_NUMBER, mPhone.getMeid());
setSummaryText(KEY_MIN_NUMBER, mPhone.getCdmaMin());
if (getResources().getBoolean(R.bool.config_msid_enable)) {
findPreference(KEY_MIN_NUMBER).setTitle(R.string.status_msid_number);
}
setSummaryText(KEY_PRL_VERSION, mPhone.getCdmaPrlVersion());
removePreferenceFromScreen(KEY_IMEI_SV);
if (mPhone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
// Show ICC ID and IMEI for LTE device
setSummaryText(KEY_ICC_ID, mPhone.getIccSerialNumber());
setSummaryText(KEY_IMEI, mPhone.getImei());
} else {
// device is not GSM/UMTS, do not display GSM/UMTS features
// check Null in case no specified preference in overlay xml
removePreferenceFromScreen(KEY_IMEI);
removePreferenceFromScreen(KEY_ICC_ID);
}
} else {
setSummaryText(KEY_IMEI, mPhone.getDeviceId());
setSummaryText(KEY_IMEI_SV,
((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
.getDeviceSoftwareVersion());
// device is not CDMA, do not display CDMA features
// check Null in case no specified preference in overlay xml
removePreferenceFromScreen(KEY_PRL_VERSION);
removePreferenceFromScreen(KEY_MEID_NUMBER);
removePreferenceFromScreen(KEY_MIN_NUMBER);
removePreferenceFromScreen(KEY_ICC_ID);
// only show area info when SIM country is Brazil
if ("br".equals(mTelephonyManager.getSimCountryIso())) {
mShowLatestAreaInfo = true;
}
}
Upvotes: 2
Reputation: 12733
In Dual Sim Devices, they have two IMEI Numbers for each SIM Slots. both are static. First IMEI No. is for First Slot and Second No. is for Second Slot.
Upvotes: 0