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.
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