How to detect SIM card change in an Android phone?

His very unpleasant situation is now in the project. I was stuck at some point. I want to do a simple task as follows

  • When someone changes the SIM card, it detects this event and checks if this new SIM card is different from the previous SIM card and takes appropriate measures.
  • I do not want to periodically check SIM_STATE with a timer or something else.
  • How does android notify you when a SIM card changes state? If yes, please tell me that I can detect a SIM card change?

I also asked this question, but I did not get a solid answer. This is a very important API and no one cares about it. Please provide me a code snippet if you have ...

I am stuck here in the documentation for servicing Android telephony, I can’t understand anything ... It will be very useful if someone can provide some code for the above.

+4
source share
2 answers

Yes, you can only do this when you restart the application, when downloading, so we need to register the receiver of the download time in our application. and when the user changes it, we can analyze it.

+1
source

When starting the application Save the SIM(Subscriber ID) .

Then each restart receives a SIM (Subscriber ID) and compares with the previous one that you save.

And to search for a subscriber number -

IMSI = m_telephonyManager.getSubscriberId ();

+1
source

All Articles