I want to detect whether two SIM cards are there in my dual-SIM android phone programmatically. I found one API (TelephonyManager.getSIMState()
), but it is for normal single-SIM phones. Are there any APIs to detect whether or not two SIMs are inserted in my dual-SIM phone?

- 1,410
- 13
- 17

- 734
- 1
- 11
- 22
-
1[Here is full solution for what you are looking for](http://stackoverflow.com/a/17499889/703851) – Vaibhav Jani Jul 06 '13 at 05:50
-
Try use MultiSim library: http://stackoverflow.com/a/41544422/1665964 – Tapa Save Jan 10 '17 at 06:59
4 Answers
Android does not support multiple SIMs, at least from the SDK. Device manufacturers who have created multi-SIM devices are doing so on their own. You are welcome to contact your device manufacturer and see if they have an SDK add-on or something that allows you to access the second SIM.
Edit: (15th July, 2015)
Since API 22, you can check for multiple SIMs using SubscriptionManager
's method getActiveSubscriptionInfoList()
. More details on Android Docs.

- 2,169
- 4
- 33
- 59

- 986,068
- 189
- 2,389
- 2,491
-
4It would be better to mention the version of SDK that is been mentioned in the answer. When this answer is viewed after many years, the statement made might mislead. – Narayanan Apr 09 '15 at 07:10
-
-
there are several ways to detect dual sim via java reflection, yes officially not possible, but in most cases there is some hacks, see: http://stackoverflow.com/questions/14517338/android-check-whether-the-phone-is-dual-sim – Amir Hossein Ghasemi Jan 18 '16 at 11:16
-
@CommonsWare The problem with `getActiveSubscriptionInfoList()` is that it only returns the active SIM's, ie, if a dual sim device only has a SIM on it, `getActiveSubscriptionInfoList()` will return a list with only one element. As of API 23, `TelepfonyManager.getPhoneCount()` returns the number of SIM slots. – Favolas Nov 23 '16 at 10:33
-
Is it possible to get which one is set as the default for a phone call (if there is any) ? – android developer Jul 17 '23 at 09:45
-
-
@CommonsWare Seems it's this one: https://developer.android.com/reference/android/telecom/TelecomManager#getDefaultOutgoingPhoneAccount(java.lang.String) . Not sure what else I can put as a parameter but this works fine: `telecomManager.getDefaultOutgoingPhoneAccount("tel")` . Found answer from here: https://stackoverflow.com/a/69221415/878126 – android developer Jul 17 '23 at 10:53
From now, if the phone is MTK powered one, you can use TelephonyManagerEx class from MediaTek SDK.
Take a look at the docs.

- 1,380
- 17
- 28

- 1,556
- 15
- 14
-
Ostensibly [bcm_ds branch](https://code.google.com/p/android/issues/detail?id=14799#c26) or MediaTek SDK to be standard in [Android One](https://en.wikipedia.org/wiki/Android_One). Both [add the](https://android.googlesource.com/platform/packages/providers/TelephonyProvider/+/b09babbf321c225b14abb013a6e1ed7041c45d06/src/com/android/providers/telephony/SmsProvider.java#275) `SmsManager.getDefault(slotId)` API. Launched simultaneously dual sim standard in Android One and MediaTek SDK and are partners. Enhancement [closed "obsolete"](https://code.google.com/p/android/issues/detail?id=14799#c27). – Shelby Moore III Dec 21 '14 at 06:33
-
final SubscriptionManager subscriptionManager = SubscriptionManager.from(getApplicationContext());
final List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
int simCount = activeSubscriptionInfoList.size();
btnBack.setText(simCount+" Sim available");
Log.d("MainActivity: ","simCount:" +simCount);
for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
Log.d("MainActivity: ","iccId :"+ subscriptionInfo.getIccId()+" , name : "+ subscriptionInfo.getDisplayName());
}

- 181
- 2
- 10
Well, this is not fool proof. But if you have two SIMs which are on two different network operators you can try something like this:
PhoneServiceStateListener listener = new PhoneServiceStateListener(this);
tm.listen(listener, PhoneStateListener.LISTEN_SERVICE_STATE);
.
.
.
class PhoneServiceStateListener extends PhoneStateListener {
Context context = null;
public PhoneServiceStateListener(Context context) {
this.context = context;
}
public PhoneServiceStateListener() {
}
@Override
public void onServiceStateChanged(ServiceState serviceState) {
if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
//You get this event when your SIM is in service.
//If you get this event twice, chances are more that your phone is Dual SIM.
//Alternatively, you can toggle Flight Mode programmatically twice so
//that you'll get service state changed event.
}
super.onServiceStateChanged(serviceState);
}
}
Ideally you'll get SIM service state changed event for both the SIMs and then you can check for network operator name or something like that to check if you have two SIM cards. But you need to have two SIM cards running on two different networks.

- 15,845
- 24
- 74
- 114