问题
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!
回答1:
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;
}
来源:https://stackoverflow.com/questions/21694440/check-if-a-sim-card-network-service-is-available-or-not