0
Hello,
I wonder if it is possible to check if the sim card on the device is installed on Android.
0
Hello,
I wonder if it is possible to check if the sim card on the device is installed on Android.
2
A quick consultation in the documentation reveals the function TelephonyManager.getSimState()
. 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 even set a callback to notify that the SIM situation changes:
telephony.listen(new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
// Verifique aqui a situação do SIM
}
});
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
It is worth believing that some Telephonymanager states are also applied with the SIM Card inserted in the device (
SIM_STATE_NETWORK_LOCKED
and others), I think only theSIM_STATE_ABSENT
and theSIM_STATE_UNKNOWN
may mean that the SIM card is not present. And still worth remembering that there may be devices with 2 Slot’s, and this method only returns the state of the first Slot.– Wakim
Worked perfectly.
– Douglas Mesquita