且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android双SIM卡信号强度

更新时间:2023-01-06 12:44:53

感谢答案!我没有尝试过您的解决方案,但是我找到了自己的解决方案.

Thanks for the answer headuck! I have not tried your solution, but i found my own solution which worked.

可以为TelephonyManager使用不同的构造函数,您可以在其中传递要控制的sim卡插槽:

It is possible to use a different constructor for the TelephonyManager where you can pass in the sim card slot you want control over:

    MultiSimClass = Class.forName("android.telephony.MultiSimTelephonyManager");

    for (Constructor<?> constructor : MultiSimClass.getConstructors()){
         if (constructor.getParameterTypes().length == 2){
              try {
                   multiSimTelephonyManager1 = constructor.newInstance(context,0);
                   multiSimTelephonyManager2 = constructor.newInstance(context,1);
             }
         }
     }