Get IMSI Number of Android Dual SIM device

2019-06-07 19:39发布

问题:

I am currently using the android API

public static String get_IMSI_Number(Context context) {
    TelephonyManager tel = (TelephonyManager) context
            .getSystemService(Context.TELEPHONY_SERVICE);
    return tel.getSubscriberId();
}

to get the IMSI number.

But unfortunately it is not getting the IMSI number if the device is dual SIM and It is returning "null" always.

I want to get the IMSI number of the Device( For Dual SIM )

case 1: Need to read the IMSI numbers if the device inserted with two SIMS in it's two slots

case 2: Need to read the IMSI number if the device inserted with one SIM in it's first slot and second slot left unused/blank

case 3: Need to read the IMSI number if the device inserted with one SIM in it's second slot and first slot left unused/blank

I followed the link "Android : Check whether the phone is dual SIM" but not worked.

Can any one help me to sort it out.

Note:The solution should work in all android 4.0 and above versions and in all vendors(Samsung,motorola,HTC,Karbon etc).

Thanks in advance.