Reputation: 31
In android, how do I capture the event of SIM card removal? Usually on phones like htc 1x, we can remove the SIM card without removing the battery and there is no notification as such of power off or restart of the phone. I want to capture the event of SIM card removal, so that I can pop-up some messages.
Upvotes: 3
Views: 6364
Reputation: 40854
According to this answer, the system sends out an android.intent.action.SIM_STATE_CHANGED
intent when the SIM card when the SIM card changes, for example when entering or leaving airplane mode, and presumably also when removing or inserting a SIM card.
It should be noted that as this is an undocumented API that may change without notice, and it may also not be available on some devices.
As for shutting down or restarting, according to this answer, the system sends out an android.intent.action.ACTION_SHUTDOWN
intent (on Android 1.6 or later).
Upvotes: 2
Reputation: 11452
Check answer number one, You can check whether the sim card is available or not in device by using TelephonyManager
class.
How can I check whether the Sim Card is available in an android device?
Upvotes: 2