SIM state detection issue on LG-P500

1.5k Views Asked by At

My app needs to check SIM card status before performing an action. So for that I use the TelephonyManager.getSimState () . If app see state as SIM_STATE_READY then it proceeds else show error to the user. This so far has worked well, but recently I got complains from LG-P500 (LG Optimus One ) device owners saying that although user has SIM card inserted in device and is able to make/receive calls my application keeps giving error about SIM card.

Logs from user shows that on device I get sim state as SIM_STATE_UNKNOWN (0) .

OS Version :2.3.3
Brand :lge
Device :thunderg

Is LG any way managing Sim state differently or LG somehow treats SIM_STATE_UNKNOWN and SIM_STATE_READY same ?

Thanks,

Tushar

2

There are 2 best solutions below

0
On

The doc says

public static final int SIM_STATE_UNKNOWN

SIM card state: Unknown. Signifies that the SIM is in transition between states. For example, when the user inputs the SIM pin under PIN_REQUIRED state, a query for sim status returns this state before turning to SIM_STATE_READY.

SIM_STATE_READY is not equal to SIM_STATE_UNKNOW

Reason for showing unknown could be many. Also, chances are that it is in CDMA network hence might not have SIM or Access to it.

0
On

I have the same problem with only LG P500 since 2.3, on 2.2 works fine. To detect if SIM ready you can use

`TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

String imsi = tm.getSubscriberId();`

if imsi is not null SIM is ready.

Also on LG P500 works PhoneStateListener and you can use it.