How to monitor SIM state change

后端 未结 3 1884
孤独总比滥情好
孤独总比滥情好 2020-11-27 14:15

I\'d like to be able to do some stuff when the SIM state change, i.e. play a sound when SIM PIN is required, but I think there are no Broadcast events that can be intercepte

3条回答
  •  广开言路
    2020-11-27 14:37

    The Intent android.intent.action.SIM_STATE_CHANGED is broadcast when the SIM state changes. For example, on my HTC Desire with a T-Mobile SIM card, if I put the device into flight mode the following Intent is broadcast:

    • Intent: android.intent.action.SIM_STATE_CHANGED with extras: ss = NOT_READY, reason = null

    If I then take it out of flight mode, the following Intents are broadcast:

    • Intent: android.intent.action.SIM_STATE_CHANGED with extras: ss = LOCKED, reason = PIN
    • Intent: android.intent.action.SIM_STATE_CHANGED with extras: ss = READY, reason = null
    • Intent: android.intent.action.SIM_STATE_CHANGED with extras: ss = IMSI, reason = null
    • Intent: android.intent.action.SIM_STATE_CHANGED with extras: ss = LOADED, reason = null

    It is possible that different manufacturers and different models behave differently. As they say, "Your mileage may vary".

提交回复
热议问题