3

Hi I am developing an application that changes a button according to the SIM STATE

I am using 1 for NO SIM and 5 for SIM READY

In few case I have no service for example, if the SIM card is an international card , It doesn't work in other places. What is the SIM State for this type of condition.

Please suggest how to check when there is a SIM card but no service. Thanks!

sanjana
  • 641
  • 2
  • 15
  • 36

1 Answers1

6

Hi Please can you try this code...

ref link : https://stackoverflow.com/a/3982768/900338

TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMgr.getSimState();
        switch (simState) {
            case TelephonyManager.SIM_STATE_ABSENT:
                // do something
                break;
            case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
                // do something
                break;
            case TelephonyManager.SIM_STATE_PIN_REQUIRED:
                // do something
                break;
            case TelephonyManager.SIM_STATE_PUK_REQUIRED:
                // do something
                break;
            case TelephonyManager.SIM_STATE_READY:
                // do something
                break;
            case TelephonyManager.SIM_STATE_UNKNOWN:
                // do something
                break;
        }
Community
  • 1
  • 1
Bhavesh Vadalia
  • 805
  • 6
  • 23