114

After a lot of research on forums, now I know that there is no way to find IMSI or SIM serial number for both the SIM cards in a dual SIM phone (except for contacting the manufacturer). Now my changed question is, can we at all detect that the phone has two SIMs? I believe it can be detected with some intelligence. Few ways I can think of are:

  1. Dialing an USSD code and tracing the logs for IMEI number (I tried this with *139# in India. It worked.) This will give me IMEI number for the SIM from which I dialed the USSD code. (It is presumed that the phone follows android guidelines and has two IMEI numbers.)

  2. Storing the SIM serial number and/or IMSI for the SIM. And after detection of any other IMSI/Serial number even if the phone was not rebooted (i.e. the SIM was switched) by tracing some logs or by some broadcast event handling.

  3. By dialing *06# you will get to see both IMEI numbers. By some way, get those two numbers. (Something like screen capturing and image parsing for text.)

If anyone can think of some other ways, they are most welcome. I would really appreciate any kind of help regarding this. Also, if anyone has any information about any manufacturers APIs or links to contact them, please do share with the community people.

xDragonZ
  • 11,742
  • 6
  • 34
  • 52
Rajkiran
  • 14,425
  • 24
  • 69
  • 108
  • Hi Rajkiran, Finally i got the solution its working fine for me. Hope it should helpful for everyone who wants to handle Duel SIM in mobile applications. The duel SIM handle API is not documented. Please check my answer its working fine for me. http://stackoverflow.com/questions/17618651/detect-target-phone-number-on-incoming-call/21448605#21448605 – Jebasuthan Feb 01 '14 at 06:27
  • 1
    Thanks.. but your answer does not answer my question. I want all the details about the second SIM and IMEI. @Pied Piper's answer helps me get everything. – Rajkiran Feb 04 '14 at 15:43
  • @Rajkiran Pied Piper's answer really helped you? I have checked his code in m samsung galaxy y duos but its not working.Did you help me to find IMEI nos of dual sim phone? – Nitish Patel Feb 20 '14 at 11:26
  • @nitishpatel : Yes definately it helped. Unfortunately I do not have Y Duos to check. But I believe Samsung uses different mechanism for dual SIM handling on android version 4.0 onwards. Pied Pipers answer helps in 4.0 onwards devices. For the rest, you'll need to dig a bit more using reflection. – Rajkiran Feb 21 '14 at 06:41
  • Hi, I find a Solution...please check code http://stackoverflow.com/a/32304799/3131373 It is tested on various phone – user3131373 Jan 12 '16 at 15:04
  • any solution with cordova? – Shri Mar 09 '16 at 04:57
  • @Shri I don't think I know much about Cordova but can't you write a method which will call Android Native code? – Rajkiran Mar 09 '16 at 05:29
  • You can try use `MultiSim` library: http://stackoverflow.com/a/41544422/1665964 – Tapa Save Jan 09 '17 at 11:34

8 Answers8

186

Update 23 March'15 :

Official multiple SIM API is available now from Android 5.1 onwards

Other possible option :

You can use Java reflection to get both IMEI numbers.

Using these IMEI numbers you can check whether the phone is a DUAL SIM or not.

Try following activity :

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TelephonyInfo telephonyInfo = TelephonyInfo.getInstance(this);

        String imeiSIM1 = telephonyInfo.getImsiSIM1();
        String imeiSIM2 = telephonyInfo.getImsiSIM2();

        boolean isSIM1Ready = telephonyInfo.isSIM1Ready();
        boolean isSIM2Ready = telephonyInfo.isSIM2Ready();

        boolean isDualSIM = telephonyInfo.isDualSIM();

        TextView tv = (TextView) findViewById(R.id.tv);
        tv.setText(" IME1 : " + imeiSIM1 + "\n" +
                " IME2 : " + imeiSIM2 + "\n" +
                " IS DUAL SIM : " + isDualSIM + "\n" +
                " IS SIM1 READY : " + isSIM1Ready + "\n" +
                " IS SIM2 READY : " + isSIM2Ready + "\n");
    }
}

And here is TelephonyInfo.java :

import java.lang.reflect.Method;

import android.content.Context;
import android.telephony.TelephonyManager;

public final class TelephonyInfo {

    private static TelephonyInfo telephonyInfo;
    private String imeiSIM1;
    private String imeiSIM2;
    private boolean isSIM1Ready;
    private boolean isSIM2Ready;

    public String getImsiSIM1() {
        return imeiSIM1;
    }

    /*public static void setImsiSIM1(String imeiSIM1) {
        TelephonyInfo.imeiSIM1 = imeiSIM1;
    }*/

    public String getImsiSIM2() {
        return imeiSIM2;
    }

    /*public static void setImsiSIM2(String imeiSIM2) {
        TelephonyInfo.imeiSIM2 = imeiSIM2;
    }*/

    public boolean isSIM1Ready() {
        return isSIM1Ready;
    }

    /*public static void setSIM1Ready(boolean isSIM1Ready) {
        TelephonyInfo.isSIM1Ready = isSIM1Ready;
    }*/

    public boolean isSIM2Ready() {
        return isSIM2Ready;
    }

    /*public static void setSIM2Ready(boolean isSIM2Ready) {
        TelephonyInfo.isSIM2Ready = isSIM2Ready;
    }*/

    public boolean isDualSIM() {
        return imeiSIM2 != null;
    }

    private TelephonyInfo() {
    }

    public static TelephonyInfo getInstance(Context context){

        if(telephonyInfo == null) {

            telephonyInfo = new TelephonyInfo();

            TelephonyManager telephonyManager = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE));

            telephonyInfo.imeiSIM1 = telephonyManager.getDeviceId();;
            telephonyInfo.imeiSIM2 = null;

            try {
                telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceIdGemini", 0);
                telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceIdGemini", 1);
            } catch (GeminiMethodNotFoundException e) {
                e.printStackTrace();

                try {
                    telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceId", 0);
                    telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceId", 1);
                } catch (GeminiMethodNotFoundException e1) {
                    //Call here for next manufacturer's predicted method name if you wish
                    e1.printStackTrace();
                }
            }

            telephonyInfo.isSIM1Ready = telephonyManager.getSimState() == TelephonyManager.SIM_STATE_READY;
            telephonyInfo.isSIM2Ready = false;

            try {
                telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimStateGemini", 0);
                telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimStateGemini", 1);
            } catch (GeminiMethodNotFoundException e) {

                e.printStackTrace();

                try {
                    telephonyInfo.isSIM1Ready = getSIMStateBySlot(context, "getSimState", 0);
                    telephonyInfo.isSIM2Ready = getSIMStateBySlot(context, "getSimState", 1);
                } catch (GeminiMethodNotFoundException e1) {
                    //Call here for next manufacturer's predicted method name if you wish
                    e1.printStackTrace();
                }
            }
        }

        return telephonyInfo;
    }

    private static String getDeviceIdBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException {

        String imei = null;

        TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        try{

            Class<?> telephonyClass = Class.forName(telephony.getClass().getName());

            Class<?>[] parameter = new Class[1];
            parameter[0] = int.class;
            Method getSimID = telephonyClass.getMethod(predictedMethodName, parameter);

            Object[] obParameter = new Object[1];
            obParameter[0] = slotID;
            Object ob_phone = getSimID.invoke(telephony, obParameter);

            if(ob_phone != null){
                imei = ob_phone.toString();

            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new GeminiMethodNotFoundException(predictedMethodName);
        }

        return imei;
    }

    private static  boolean getSIMStateBySlot(Context context, String predictedMethodName, int slotID) throws GeminiMethodNotFoundException {

        boolean isReady = false;

        TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        try{

            Class<?> telephonyClass = Class.forName(telephony.getClass().getName());

            Class<?>[] parameter = new Class[1];
            parameter[0] = int.class;
            Method getSimStateGemini = telephonyClass.getMethod(predictedMethodName, parameter);

            Object[] obParameter = new Object[1];
            obParameter[0] = slotID;
            Object ob_phone = getSimStateGemini.invoke(telephony, obParameter);

            if(ob_phone != null){
                int simState = Integer.parseInt(ob_phone.toString());
                if(simState == TelephonyManager.SIM_STATE_READY){
                    isReady = true;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new GeminiMethodNotFoundException(predictedMethodName);
        }

        return isReady;
    }


    private static class GeminiMethodNotFoundException extends Exception {

        private static final long serialVersionUID = -996812356902545308L;

        public GeminiMethodNotFoundException(String info) {
            super(info);
        }
    }
}

Edit :

Getting access of methods like "getDeviceIdGemini" for other SIM slot's detail has prediction that method exist.

If that method's name doesn't match with one given by device manufacturer than it will not work. You have to find corresponding method name for those devices.

Finding method names for other manufacturers can be done using Java reflection as follows :

public static void printTelephonyManagerMethodNamesForThisDevice(Context context) {

    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    Class<?> telephonyClass;
    try {
        telephonyClass = Class.forName(telephony.getClass().getName());
        Method[] methods = telephonyClass.getMethods();
        for (int idx = 0; idx < methods.length; idx++) {

            System.out.println("\n" + methods[idx] + " declared by " + methods[idx].getDeclaringClass());
        }
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
} 

EDIT :

As Seetha pointed out in her comment :

telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceIdDs", 0);
telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceIdDs", 1); 

It is working for her. She was successful in getting two IMEI numbers for both the SIM in Samsung Duos device.

Add <uses-permission android:name="android.permission.READ_PHONE_STATE" />

EDIT 2 :

The method used for retrieving data is for Lenovo A319 and other phones by that manufacture (Credit Maher Abuthraa):

telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getSimSerialNumberGemini", 0); 
telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getSimSerialNumberGemini", 1); 
Vaibhav Jani
  • 12,018
  • 10
  • 60
  • 71
  • 4
    Cool! That worked for me with "getDeviceId" on Karbonn. Will search for Samsung methods and will update here when I have it with me. Thanks man. Kudos. – Rajkiran Jul 08 '13 at 12:18
  • I was successful in getting IMSI numbers for both the SIM cards on Karbonn phones. I tried a lot to get 2 IMEI numbers or SIM info for both the SIMs for `Samsung`. But somehow `I couldn't`. Can you please check on Samsung dual SIM phones and let us know? If possible please contact me through my profile. – Rajkiran Jul 12 '13 at 06:19
  • Unfortunately I didn't found any direct straight forward declared method to get second IMEI by printing list of telephony class methods in Samsung devices so I am also finding any clue for other way. If I will get that I'll surely update here. – Vaibhav Jani Jul 12 '13 at 06:30
  • 1
    Yes. Even I did that. Found that Samsung uses `com.android.internal.telephony.RILConstants$SimCardID` internally. Even tried creating that class with the same signature of methods and same names of variables. But no luck. Will try getting source code and will try to check. Thanks. – Rajkiran Jul 12 '13 at 06:49
  • Can you tell me please, is it possible to disable 1 of 2 SIM cards or turn on airplane mode for it, using this methods or/and information, that is got using them? – artem Jul 12 '13 at 17:43
  • In **edit** section of answer I posted method that display all method names of telephony class, you can find your useful method if any. – Vaibhav Jani Jul 13 '13 at 04:09
  • @Pied Piper I used getLine1Number to get user mobile number and match with user entered no for mobile number verification .But when i used dual sim mobile for testing. my application was crashed .I check your code but in that you did not specified how to get dual sim mobile's both sim's no..Thanks in advance – Mahi Dec 03 '13 at 10:23
  • @MahiSingh In edit section of answer I posted method that prints all method names of telephony class for particular device, from which you can find methods that give you any required SIM card info then you reflect it as we did for IMEI. – Vaibhav Jani Dec 03 '13 at 10:28
  • Are u succeeded with Samsung dual Sim details. Please share. Thanks – Riskhan Mar 08 '14 at 10:59
  • 4
    I use telephonyInfo.imeiSIM1 = getDeviceIdBySlot(context, "getDeviceIdDs", 0);telephonyInfo.imeiSIM2 = getDeviceIdBySlot(context, "getDeviceIdDs", 1); It is working for me. I was successful in getting two IMEI numbers for both the SIM. – Seetha May 02 '14 at 10:33
  • @Seetha Great. For which device? – Vaibhav Jani May 02 '14 at 15:20
  • Unable to calculate signal strength of the other SIM, because no method is available of listen() is available which accepts slotID. Which is there for other methods such as getDeviceId(int). Please help. – VishalKale Jul 01 '14 at 10:48
  • @VishalKale See list of methods for devices and find out useful method to be invoked is only solution. – Vaibhav Jani Jul 01 '14 at 11:45
  • 1
    How can I get Phone number of SIM2? I am getting SIM1 number using telephony.getLine1Number() method, in the list of method I cant find method like getLine2Number() or getLine1Number(int) – DCoder Mar 18 '15 at 06:50
  • See list of methods for devices and find out useful method to be invoked is only solution – Vaibhav Jani Mar 18 '15 at 21:23
  • 1
    The method used for retrieving data is for Lenovo A319 and other phones by that manufacture: telephonyInfo.imsiSIM1 = getDeviceIdBySlot(context, "getSimSerialNumberGemini", 0); telephonyInfo.imsiSIM2 = getDeviceIdBySlot(context, "getSimSerialNumberGemini", 1); please to update your answer.. thanks btw :-) – Maher Abuthraa Apr 26 '15 at 07:05
  • 1
    sorry Vaibhav, the methods I did provided are for serialNumber not IMSI.. I couldn't get IMSIs for dual device by this way .. i made it with this way : http://stackoverflow.com/a/30647918/2267723 – Maher Abuthraa Jun 04 '15 at 15:45
  • 4
    deviceId is IMEI not IMSI, isn't it? – falko Jul 26 '15 at 11:06
  • @Seetha Can you tell me method name for getSubscriberId ? – falko Jul 26 '15 at 11:18
  • @DCoder have you found something to get the phone number from dual sim phone for both SIMs – rupesh Aug 18 '15 at 08:08
  • Can you plz help me to get operator name in dual sim – Aneh Thakur Nov 17 '15 at 11:19
  • what i can do for sending message from specific sim? – Mahdi Dec 28 '15 at 09:54
  • 1
    add this please for samsung sim state change: `"getSimStateDs"`, this seem not any additional names for this two methods, I found these info on this forum, more than 200+ phone print their information: http://4pda.ru/forum/lofiversion/index.php?t632334.html – Amir Hossein Ghasemi Jan 18 '16 at 05:35
  • any solution with cordova? – Shri Mar 09 '16 at 04:56
  • 1
    Hi, the two java classes exposed works fine on HONOR7 DUAL SIM (HUWAEI). – felice.murolo Mar 28 '16 at 08:57
  • 1
    how to get phone number ? – Sagar Nayak Mar 30 '16 at 04:53
  • Can above solution tell the carrier/operator name of both sims? – Muhammad Babar Aug 15 '16 at 10:12
  • The above code is working fine..i have two sim, one is active, another sim is waiting for customer care activation, but, second sim also showing Simready true only(2nd sim tower not shown, still, waiting for New Sim Activation).. can anyone tell how to detect this scenario state ? – harikrishnan Aug 22 '16 at 13:09
  • How is it possible to get second sim cards phone number? – KAPLANDROID Jun 05 '17 at 20:54
  • telephonyInfo.imsiSIM1 = telephonyManager.getDeviceId(); This is wrong here, getDeviceId() will return IMEI, not IMSI. IMEI and IMSI they are totally different. Please don't mislead other people. – DàChún Jul 04 '17 at 13:23
  • @User9527 corrected :) Initially I called it IMEI but someone [miss guided](https://stackoverflow.com/revisions/17499889/8) me about it. Anyway it can determine whether phone is dual SIM or not :) – Vaibhav Jani Jul 06 '17 at 02:15
  • 1
    `telephonyManager.getDeviceId()` when targeting Android > M, there will be an error: Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException – HendraWD Nov 23 '17 at 12:23
  • I want to get the SIM SERIAL NUMBER for DUAL SIM devices, not the IMEI number for the devices targetting API < 22. I am getting the SIM SERIAL NUMBER for devices targetting API >= 22 with the help of SubscriptionManager added in API 22. i want for API < 22. dual SIM, single SIM i am getting with the help of telephonymanager. – Aman Verma Dec 15 '17 at 20:18
  • 1
    It seems there is also source code on github https://github.com/ITger/DualSIMCard – Vlad Nov 14 '19 at 12:17
5

I have a Samsung Duos device with Android 4.4.4 and the method suggested by Seetha in the accepted answer (i.e. call getDeviceIdDs) does not work for me, as the method does not exist. I was able to recover all the information I needed by calling method "getDefault(int slotID)", as shown below:

public static void samsungTwoSims(Context context) {
    TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    try{

        Class<?> telephonyClass = Class.forName(telephony.getClass().getName());

        Class<?>[] parameter = new Class[1];
        parameter[0] = int.class;
        Method getFirstMethod = telephonyClass.getMethod("getDefault", parameter);

        Log.d(TAG, getFirstMethod.toString());

        Object[] obParameter = new Object[1];
        obParameter[0] = 0;
        TelephonyManager first = (TelephonyManager) getFirstMethod.invoke(null, obParameter);

        Log.d(TAG, "Device Id: " + first.getDeviceId() + ", device status: " + first.getSimState() + ", operator: " + first.getNetworkOperator() + "/" + first.getNetworkOperatorName());

        obParameter[0] = 1;
        TelephonyManager second = (TelephonyManager) getFirstMethod.invoke(null, obParameter);

        Log.d(TAG, "Device Id: " + second.getDeviceId() + ", device status: " + second.getSimState()+ ", operator: " + second.getNetworkOperator() + "/" + second.getNetworkOperatorName());
    } catch (Exception e) {
        e.printStackTrace();
    }   
}

Also, I rewrote the code that iteratively tests for methods to recover this information so that it uses an array of method names instead of a sequence of try/catch. For instance, to determine if we have two active SIMs we could do:

private static String[] simStatusMethodNames = {"getSimStateGemini", "getSimState"};


public static boolean hasTwoActiveSims(Context context) {
    boolean first = false, second = false;

    for (String methodName: simStatusMethodNames) {
        // try with sim 0 first
        try {
            first = getSIMStateBySlot(context, methodName, 0);
            // no exception thrown, means method exists
            second = getSIMStateBySlot(context, methodName, 1);
           return first && second;
        } catch (GeminiMethodNotFoundException e) {
            // method does not exist, nothing to do but test the next
        }
    }
    return false;
}

This way, if a new method name is suggested for some device, you can simply add it to the array and it should work.

4

I am able to read both the IMEI's from OnePlus 2 Phone

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                TelephonyManager manager = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
                Log.i(TAG, "Single or Dual Sim " + manager.getPhoneCount());
                Log.i(TAG, "Default device ID " + manager.getDeviceId());
                Log.i(TAG, "Single 1 " + manager.getDeviceId(0));
                Log.i(TAG, "Single 2 " + manager.getDeviceId(1));
            }
Ajith Ramesh
  • 133
  • 13
Swapnil Godambe
  • 2,014
  • 1
  • 22
  • 28
4

There are several native solutions I've found while searching the way to check network operator.

For API >=17:

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);

// Get information about all radio modules on device board
// and check what you need by calling #getCellIdentity.

final List<CellInfo> allCellInfo = manager.getAllCellInfo();
for (CellInfo cellInfo : allCellInfo) {
    if (cellInfo instanceof CellInfoGsm) {
        CellIdentityGsm cellIdentity = ((CellInfoGsm) cellInfo).getCellIdentity();
        //TODO Use cellIdentity to check MCC/MNC code, for instance.
    } else if (cellInfo instanceof CellInfoWcdma) {
        CellIdentityWcdma cellIdentity = ((CellInfoWcdma) cellInfo).getCellIdentity();
    } else if (cellInfo instanceof CellInfoLte) {
        CellIdentityLte cellIdentity = ((CellInfoLte) cellInfo).getCellIdentity();
    } else if (cellInfo instanceof CellInfoCdma) {
        CellIdentityCdma cellIdentity = ((CellInfoCdma) cellInfo).getCellIdentity();
    } 
}

In AndroidManifest add permission:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>

To get network operator you can check mcc and mnc codes:

For API >=22:

final SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
final List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
    final CharSequence carrierName = subscriptionInfo.getCarrierName();
    final CharSequence displayName = subscriptionInfo.getDisplayName();
    final int mcc = subscriptionInfo.getMcc();
    final int mnc = subscriptionInfo.getMnc();
    final String subscriptionInfoNumber = subscriptionInfo.getNumber();
}

For API >=23. To just check if phone is dual/triple/many sim:

TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (manager.getPhoneCount() == 2) {
    // Dual sim
}
oxied
  • 1,488
  • 16
  • 14
2

I was taking a look at the call logs and I noticed that apart from the usual fields in the contents of managedCursor, we have a column "simid" in Dual SIM phones (I checked on Xolo A500s Lite), so as to tag each call in the call log with a SIM. This value is either 1 or 2, most probably denoting SIM1/SIM2.

managedCursor = context.getContentResolver().query(contacts, null, null, null, null);
managedCursor.moveToNext();        
for(int i=0;i<managedCursor.getColumnCount();i++)
{//for dual sim phones
    if(managedCursor.getColumnName(i).toLowerCase().equals("simid"))
        indexSIMID=i;
}

I did not find this column in a single SIM phone (I checked on Xperia L).

So although I don't think this is a foolproof way to check for dual SIM nature, I am posting it here because it could be useful to someone.

zafar142003
  • 1,962
  • 2
  • 16
  • 29
  • You are reading a DB, which one? Please clarify what you are doing here. (Where is the "contacts" db stored? – not2qubit Jan 24 '17 at 15:11
1

Tips:

You can try to use

ctx.getSystemService("phone_msim")

instead of

ctx.getSystemService(Context.TELEPHONY_SERVICE)

If you have already tried Vaibhav's answer and telephony.getClass().getMethod() fails, above is what works for my Qualcomm mobile.

Nirav Zaveri
  • 646
  • 1
  • 8
  • 27
Bruce
  • 2,036
  • 2
  • 23
  • 20
  • As long as the answer is *complete* you may post links to web pages in other languages for supplementary information. http://meta.stackoverflow.com/questions/271060/is-it-ok-if-i-add-links-to-non-english-written-posts-in-a-so-answer – mach Dec 01 '14 at 08:29
  • That was actually a [useful link](http://blog.csdn.net/peijiangping1989/article/details/20448007), no need to remove it. – not2qubit Feb 01 '17 at 13:06
0

I have found these system properties on Samsung S8

SystemProperties.getInt("ro.multisim.simslotcount", 1) > 1

Also, according to the source: https://android.googlesource.com/platform/frameworks/base/+/master/telephony/java/com/android/internal/telephony/TelephonyProperties.java

getprop persist.radio.multisim.config returns "dsds" or "dsda" on multi sim.

I have tested this on Samsung S8 and it works

kakopappa
  • 4,849
  • 4
  • 49
  • 72
  • Never mind. Android already has APIs for dual SIM now. https://developer.android.com/about/versions/android-5.1.html#multisim For everything else, you can refer to above answer by @vaibhav – Rajkiran May 25 '17 at 09:49
-2

Commonsware says this is not possible. Please see the following:

Detecting Dual SIM using Android SDK is not possible.

Here is further dialog on the subject:

Google dev team guy says detecting Dual SIM using Android SDK is not possible.

Community
  • 1
  • 1
gonzobrains
  • 7,198
  • 11
  • 73
  • 126
  • 3
    Yes man. I know that. But that's why I am trying to find a workaround. And there has to be some. Try USSDDualWidget app from Play Store. It can actually switch between the two SIMs. Even tried to reverse engineer the code, but no luck. – Rajkiran Apr 26 '13 at 06:56
  • Does it work on all devices or just a limited subset that expose some sort of proprietary interface? – gonzobrains Apr 26 '13 at 20:05
  • That seems to work on Samsung dual SIM phones, at least. Unfortunately, I could check only on Samsung Galaxy Y Duos and Galaxy Grand. – Rajkiran Apr 29 '13 at 07:26
  • My guess is there is some manufacturer-specific API that allows for this. I didn't even know Samsung made dual-SIM phones! – gonzobrains Apr 29 '13 at 17:38
  • There may be no universal method for working with different sims (slots), but sometimes you can get information about a particular sim using `TelephonyManager`'s methods ending with `Gemini`. E. g. `String getLine1NumberGemini(int slotId)`, where `slotId` is the sequential number of the sim card (0, 1). These methods can be invoked via reflection only. – Mentiflectax Jul 10 '13 at 13:59
  • Yes, actually I was able to use Java reflection as well for my particular case. But the code varies on a phone-by-phone basis as there is no universal way to do this. – gonzobrains Jul 10 '13 at 19:32
  • 24
    Manytimes commonsware has said **its not possible** which has been made possible by other developers. So, its not like that what commonsware says is always right :-) – Lalit Poptani Jun 12 '14 at 05:20
  • 1
    You may be correct, but I do think he is a fairly credible resource for all things Android. As for this particular issue, sure, I did the same thing and used reflection to obtain dual sim data, but it was for my particular device. To this day, I still don't believe there is any generic way to go about doing this. Also notice I quoted a Google developer as well and not just Commonsware. – gonzobrains Jun 12 '14 at 10:31
  • He has updated his answer , its time you update your answer too – Manohar Reddy Aug 17 '18 at 12:29