如何选择Sim 1或2电话管理器

时间:2018-10-25 15:53:13

标签: java android telephonymanager

在我的代码中,当用户想要在两张SIM卡的手机上使用该应用程序时,我需要检测到SIM卡。该应用程序适用于USSD。我在这里找到了一个技巧,以查找有关TelephonyManager的资源,但没有找到。请帮忙!

我的代码是

if (!depezo) {
        TelephonyManager telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

        if (depezo || telephonyManager != null) {
            String codeReseau = telephonyManager.getNetworkOperator();
            String nomReseau = telephonyManager.getNetworkOperatorName();


            //Code Airtel
            if (codeReseau.equalsIgnoreCase("63002")) {
                Toast.makeText(this, "Code Airtel", Toast.LENGTH_SHORT).show();
            //Code Vodacom
            } else if (codeReseau.equalsIgnoreCase("63901")) {
                Toast.makeText(this, "Code Vodacom", Toast.LENGTH_SHORT).show();
                //Code Africell
            } else if (codeReseau.equalsIgnoreCase("63990")) {
                Toast.makeText(this, "Code Africell", Toast.LENGTH_SHORT).show();
            //Code Orange
            } else if (codeReseau.equalsIgnoreCase("63089")) {
                Toast.makeText(this, "Code Orange 63089", Toast.LENGTH_SHORT).show();
            } else if (codeReseau.equalsIgnoreCase("63084")) {
                Toast.makeText(this, "Code Orange 63084", Toast.LENGTH_SHORT).show();
                //Nom Orange
            } else if (nomReseau.equalsIgnoreCase("Orange")) {
                Intent intent = new Intent (MainActivity.this, VodacomHome.class);
                startActivity(intent);
            } else {
                pageVide();

            }
            return;
        }
      throw new AssertionError();
  }

0 个答案:

没有答案