Check if Sim Card is installed

0

Hello,

I wonder if it's possible to check if the sim card on the device is installed on Android.

    
asked by anonymous 21.07.2014 / 16:28

1 answer

2

A quick lookup in the documentation reveals the TelephonyManager.getSimState() function. It can be used like this:

final TelephonyManager telephony = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
if (telephony.getSimState() == TelephonyManager.SIM_STATE_READY) {
    // ...
}

The value returned is one of the following:

SIM_STATE_UNKNOWN // Em transição entre dois estados
SIM_STATE_ABSENT
SIM_STATE_PIN_REQUIRED
SIM_STATE_PUK_REQUIRED
SIM_STATE_NETWORK_LOCKED
SIM_STATE_READY

You can also set a callback to notify you that the SIM situation changes:

telephony.listen(new PhoneStateListener() {
    @Override
    public void onServiceStateChanged(ServiceState serviceState) {
        // Verifique aqui a situação do SIM
    }
});
    
21.07.2014 / 16:33