How to get SIM details in android.How to get SIM details in android.

Get SIM details in android program.

Answer 1

Using the Object of Telephony Manager class we can get the details like SIM Serial number, Country Code, Network Provider code and other Details.
Declare this permission in Manifest.
    

Use this code :
  
  TelephonyManager  telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); 
  int simState = telephonyManager.getSimState();

  switch (simState) {

      case (TelephonyManager.SIM_STATE_ABSENT): break;
      case (TelephonyManager.SIM_STATE_NETWORK_LOCKED): break;
      case (TelephonyManager.SIM_STATE_PIN_REQUIRED): break;
      case (TelephonyManager.SIM_STATE_PUK_REQUIRED): break;
      case (TelephonyManager.SIM_STATE_UNKNOWN): break;
      case (TelephonyManager.SIM_STATE_READY): {

          // Get the SIM country ISO code
             String simCountry = telephonyManager.getSimCountryIso();

          // Get the operator code of the active SIM (MCC + MNC)
             String simOperatorCode = telephonyManager.getSimOperator();

          // Get the name of the SIM operator
             String simOperatorName = telephonyManager.getSimOperatorName();

          // Get the SIM’s serial number
             String simSerial = telephonyManager.getSimSerialNumber();
       }
   }

SUBMIT YOUR ANSWER

  |  
 
 
 

Preview :