How to read two IMEI, from Cell phone Dual SIM? (In Android Studio)

Diego picture Diego · Jul 21, 2015 · Viewed 7.4k times · Source

I used this line in Android Studio to get IMEI number,

"android.telephony.TelephonyManager.getDeviceId()"

and I can see the first IMEI, but I need see the second IMEI.

Update: I checked this link Android : Check whether the phone is dual SIM

but I cant resolve the second IMEI.

Answer

rafeek picture rafeek · Nov 17, 2017

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

TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE‌​);
String imeiNumber1 = tm.getDeviceId(0);
String imeiNumber2 = tm.getDeviceId(1);

Requires Permission: READ_PHONE_STATE