Basically, the answer to this question " How to track the change in SIM status " is the correct answer to your question.
So you create a new class
package abc; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class SimChangedReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent intent) { Log.d("SimChangedReceiver", "--> SIM state changed <--");
and adapt your AndroidManifest.xml to accommodate
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <application android:name="abc..." ... > <receiver android:name="abcSimChangedReceiver"> <intent-filter> <action android:name="android.intent.action.SIM_STATE_CHANGED"/> </intent-filter> </receiver> </application>
As usual on Android, there are no guarantees that it works on any version or on any manufacturers.
source share