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.
The easiest way to find it on an Android phone is to dial *#06#, after which the number should appear on your screen. If you have a dual-SIM phone, you'll see two numbers — one for each SIM slot. You can also check IMEI in your device's settings by heading to Settings> About phone > IMEI.
The simplest method of finding your phone's IMEI number is using the USSD code. This method is more or less the universal method. It works on almost all feature phones and smartphones. Dial *#06# on your phone.
Important: Only one IMEI will appear if one SIM is being used in the device even if the phone is dual SIM. If you have a dual SIM device and are using two SIM cards, there will be two IMEI numbers shown as IMEI 1 and IMEI 2. Please consider IMEI 1 as your device's identification number.
How to Check If an Android Phone is Dual-SIM. To see if the phone your using is dual-SIM, go into your phone's Settings app. Tap on Network and internet. The SIM cards option should be right below Airplane mode.
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
We can check whether phone single or dual sim by using Android API and IMEI for each sim Card
TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Log.i("OmSai ", "Single or Dula Sim "+manager.getPhoneCount());
Log.i("OmSai ", "Defualt device ID "+manager.getDeviceId());
Log.i("OmSai ", "Single 1 "+manager.getDeviceId(0));
Log.i("OmSai ", "Single 2 "+manager.getDeviceId(1));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With