How to detect the SIM card change in android phone?

有些话、适合烂在心里 提交于 2019-12-07 06:47:30

问题


Its very much frustrating situation now in project. I am stuck up at one point. I want do a simple task as follows

  1. When someone change the SIM, detect this event and check if this new SIM is different from previous SIM and take action accordingly.
  2. I don't want to check the SIM_STATE periodically by timer or anything..
  3. Do android notify the state change of SIM? If yes please let me know I can detect the SIM change?

I have asked this question before also but no solid answer I got. It seems a very important API and no one care about it. Please provide me some code snippet if you have please...

I am stuck up here and in the android telephony service documentation I don't able to understand anything... It will very helpful if anyone can provide some code for the above.


回答1:


When you start Application Save your SIM(Subscriber ID).

Then every restart fetch SIM(Subscriber ID) And Compare with previous one which you save.

And for Finding SubscriberID number --

IMSI = m_telephonyManager.getSubscriberId();




回答2:


Yes, You can do only when application restart, at boot time receiver, so we have to register boot time receiver in our application. and when user change it we can analyse it .



来源:https://stackoverflow.com/questions/11009295/how-to-detect-the-sim-card-change-in-android-phone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!