Android examples for android.telephony:TelephonyManager
Check state of SIM Card
import android.content.Context; import android.telephony.TelephonyManager; public class Main { public static String readSIMCard(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); switch (tm.getSimState()) { case TelephonyManager.SIM_STATE_ABSENT: return "ABSENT"; case TelephonyManager.SIM_STATE_UNKNOWN: return "UNKNOWN"; case TelephonyManager.SIM_STATE_NETWORK_LOCKED: return "NETWORK_LOCKED"; case TelephonyManager.SIM_STATE_PIN_REQUIRED: return "PIN_REQUIRED"; case TelephonyManager.SIM_STATE_PUK_REQUIRED: return "PUK_REQUIRED"; }/* w w w .j ava 2s .com*/ return ""; } }