Current Android Release version:
Version Code: Pie
Version: 9
API level: 28

How to retrieve Telephony information

Phone Type:

switch (mTelephonyManager.getPhoneType()) 
{
      case TelephonyManager.PHONE_TYPE_CDMA:
              mType.setText("CDMA");
              break;
      case TelephonyManager.PHONE_TYPE_GSM:
              mType.setText("GSM");
              break;
      case TelephonyManager.PHONE_TYPE_SIP:
              mType.setText("SIP");
              break;
      default:
              mType.setText("NONE");
              break;
}

Network Type:

switch (mTelephonyManager.getNetworkType()) 
{
       case TelephonyManager.NETWORK_TYPE_1xRTT:
              mNetwork.setText("1xRTT");
              break;
       case TelephonyManager.NETWORK_TYPE_CDMA:
              mNetwork.setText("CDMA");
              break;
       case TelephonyManager.NETWORK_TYPE_EDGE:
              mNetwork.setText("EDGE");
              break;
       case TelephonyManager.NETWORK_TYPE_EHRPD:
              mNetwork.setText("eHRPD");
              break;
       case TelephonyManager.NETWORK_TYPE_EVDO_0:
              mNetwork.setText("EVDO rev. 0");
              break;
       case TelephonyManager.NETWORK_TYPE_EVDO_A:
              mNetwork.setText("EVDO rev. A");
              break;
       case TelephonyManager.NETWORK_TYPE_EVDO_B:
              mNetwork.setText("EVDO rev. B");
              break;
       case TelephonyManager.NETWORK_TYPE_GPRS:
              mNetwork.setText("GPRS");
              break;
       case TelephonyManager.NETWORK_TYPE_HSDPA:
              mNetwork.setText("HSDPA");
              break;
       case TelephonyManager.NETWORK_TYPE_HSPA:
              mNetwork.setText("HSPA");
              break;
      case TelephonyManager.NETWORK_TYPE_HSPAP:
              mNetwork.setText("HSPA+");
              break;
      case TelephonyManager.NETWORK_TYPE_HSUPA:
             mNetwork.setText("HSUPA");
             break;
      case TelephonyManager.NETWORK_TYPE_IDEN:
             mNetwork.setText("iDen");
             break;
      case TelephonyManager.NETWORK_TYPE_LTE:
             mNetwork.setText("LTE");
             break;
      case TelephonyManager.NETWORK_TYPE_UMTS:
             mNetwork.setText("UMTS");
             break;
      case TelephonyManager.NETWORK_TYPE_UNKNOWN:
             mNetwork.setText("Unknown");
             break;
}


SIM State:

switch (mTelephonyManager.getSimState()) 
{
      case TelephonyManager.SIM_STATE_ABSENT:
             mState.setText("Absent");
             break;
      case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
             mState.setText("Network Locked");
             break;
      case TelephonyManager.SIM_STATE_PIN_REQUIRED:
             mState.setText("PIN Required");
             break;
      case TelephonyManager.SIM_STATE_PUK_REQUIRED:
             mState.setText("PUK Required");
             break;
      case TelephonyManager.SIM_STATE_READY:
             mState.setText("Ready");
             break;
      case TelephonyManager.SIM_STATE_UNKNOWN:
             mState.setText("Unknown");
             break;
}

No comments:

Post a Comment