How to get the name of operator which is connected to internet in dual sim android phone?

别来无恙 提交于 2019-12-05 05:54:51
xxxzhi

There are no API about multiple sims before API 22. You can contact your device manufacturer and check whether they have an SDK add-on to access multiple sims or not.

Since API 22, you can check for multiple SIMs using SubscriptionManager's method getActiveSubscriptionInfoList(). More details on Android Docs.

Please look multiple sims. Here are some discussion about multiple, Hope this can help you for finding a way to access multiple sim network.

Check this code https://github.com/dragos-niculescu/dualsim/blob/master/src/com/example/dualsim/TelephonyInfo.java

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
int dataNetworkTypeSIM1 = telephonyManager.getNetworkType();
int dataNetworkTypeSIM2 = 0;
try {
    dataNetworkTypeSIM1 = Integer.parseInt(getStringOfInt(context, "getNetworkTypeGemini", 0));
    dataNetworkTypeSIM2 = Integer.parseInt(getStringOfInt(context, "getNetworkTypeGemini", 1));
} catch (GeminiMethodNotFoundException e) {
    try {
        dataNetworkTypeSIM1 = Integer.parseInt(getStringOfInt(context, "getDataNetworkTypeGemini", 0));
        dataNetworkTypeSIM2 = Integer.parseInt(getStringOfInt(context, "getDataNetworkTypeGemini", 1));
    } catch (GeminiMethodNotFoundException e1) {
        try {
             dataNetworkTypeSIM1 = Integer.parseInt(getStringOfInt(context, "getDataNetworkType", 0));
             dataNetworkTypeSIM2 = Integer.parseInt(getStringOfInt(context, "getDataNetworkType", 1));
        } catch (GeminiMethodNotFoundException e2) {
             try {
                  dataNetworkTypeSIM1 = Integer.parseInt(getStringOfInt(context, "getNetworkType", 0));
                  dataNetworkTypeSIM2 = Integer.parseInt(getStringOfInt(context, "getNetworkType", 1));
             } catch (GeminiMethodNotFoundException e3) {}
        }
    }
}

You can get all available methods by calling:

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
Method[] methods = Class.forName(telephonyManager.getClass().getName()).getMethods();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!