Programmatically retrieve IMEI number for dual SIM in android

NehaC picture NehaC · Mar 20, 2014 · Viewed 45.6k times · Source

For single SIM following code works:

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei= tm.getDeviceId();

For dual SIM I tried code on following link:

Android : Check whether the phone is dual SIM

But it didnt work for me.

Let me know if any other solutions possible.

Answer

Dheeraj Vepakomma picture Dheeraj Vepakomma · Mar 7, 2016

Try using getDeviceId(int slotId) added in API level 23.

Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available.

Requires Permission: READ_PHONE_STATE