TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = mTelephonyManager.getSimState();
String hintMessage = "";
switch (simState) {
case TelephonyManager.SIM_STATE_UNKNOWN:
hintMessage = "Unknown";
break;
case TelephonyManager.SIM_STATE_ABSENT:
hintMessage = "no SIM card is available in the device";
break;
case TelephonyManager.SIM_STATE_PIN_REQUIRED:
hintMessage = "Locked: requires the user's SIM PIN to unlock";
break;
case TelephonyManager.SIM_STATE_PUK_REQUIRED:
hintMessage = "Locked: requires the user's SIM PUK to unlock ";
break;
case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
hintMessage = "Locked: requries a network PIN to unlock";
break;
case TelephonyManager.SIM_STATE_READY:
hintMessage = "Ready";
break;
default:
break;
}
Toast.makeText(getApplicationContext(), hintMessage, Toast.LENGTH_LONG).show();
android中判断SIM卡状态
最新推荐文章于 2023-06-23 11:16:19 发布