Search code examples
androiddual-sim

Operation on Second SIM Android


I am developing one Android app for that I need to stop and start mobile data.

The problem is that how can I determine whether the mobile is dual SIM or not?

Also if it is dual SIM then how can I do my operation on second SIM?

Thanks !


Solution

  • Safely and decently, you can't.

    If you're ready to limit your app to certain devices and give up on it being future proof, you can determine whether the mobile phone is dual SIM by trying to do something that only a specific dual SIM phone can do. If it works, it's surely dual SIM. If it doesn't, well... You won't know. Maybe it's a chipset you didn't cover.

    I'll give you an example. If you wish to cover Mediatek chipsets, try this:

    long gprsConnectionSimSetting =
        Settings.System.getLong(context.getContentResolver(),
        "gprs_connection_sim_setting");
    

    It is a Mediatek powered dual SIM phone, if gprsConnectionSimSetting holds one of these values: 0, 1 or 2.

    Value 0 stands for "mobile data disabled on both SIMs", value 1 means "mobile data goes through SIM1" and, you've guessed it, value 2 tells us that SIM2 is being used for mobile data.