How to check whether sim card exists or not in android


/**
 * @return true if SIM card exists
 * false if SIM card is locked or doesn't exists <br/><br/>
 * <b>Note:</b> This method requires permissions <b> "android.permission.READ_PHONE_STATE" </b>
 */
 public boolean isSimExists()
 {
 TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
 int SIM_STATE = telephonyManager.getSimState();

 if(SIM_STATE == TelephonyManager.SIM_STATE_READY)
 return true;
 else
 {
 switch(SIM_STATE)
 {
 case TelephonyManager.SIM_STATE_ABSENT: //SimState = "No Sim Found!";
 break;
 case TelephonyManager.SIM_STATE_NETWORK_LOCKED: //SimState = "Network Locked!";
 break;
 case TelephonyManager.SIM_STATE_PIN_REQUIRED: //SimState = "PIN Required to access SIM!";
 break;
 case TelephonyManager.SIM_STATE_PUK_REQUIRED: //SimState = "PUK Required to access SIM!"; // Personal Unblocking Code
 break;
 case TelephonyManager.SIM_STATE_UNKNOWN: //SimState = "Unknown SIM State!";
 break;
 }
 return false;
 }
 }

Advertisements

Tags:

About krishjlk

http://www.facebook.com/krishna.kanth.121

One response to “How to check whether sim card exists or not in android”

  1. funnyman says :

    hellowantWatch the funny video on “Oh Funny Tv”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: