如何监控SIM卡状态变化 [英] How to monitor SIM state change

查看:2342
本文介绍了如何监控SIM卡状态变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够做一些东西,当SIM卡状态变化,即播放声音时,SIM卡的PIN是必需的,但我认为没有任何广播的事件,可以由广播接收这个被截获.. 。报名参加的 android.intent.action 的.PHONE_STATE也只能告诉你,当呼叫状态的变化..另一种可启动的注册表服务的 PhoneStateListener 的和在反应一个LISTEN_SERVICE_STATE(当状态是OUT-OF-STATE它可以得到的SIM卡状态下从的 TelephonyManager 的,看看如果状态SIM_STATE_PIN_REQUIRED)。所以,我的问题是:

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 intercepted by a broadcast receiver for this... registering for android.intent.action.PHONE_STATE does only tell you when the CALL-STATE changes.. An alternative can be starting a service that registers a PhoneStateListener and reacts upon a LISTEN_SERVICE_STATE (when the state is OUT-OF-STATE it can get the SIM state from the TelephonyManager and look if the state is SIM_STATE_PIN_REQUIRED). So, my questions are:

1)有没有广播的意图,我可以用它来拦截SIM卡状态改变或服务状态变化?

1) Is there any broadcast intent that I can use to intercept a SIM state change or a Service State change?

2)这是个坏主意,安装的 PhoneStateListener 的内部服务,并使用它的手机状态的通知后交付意图服务本身改变接收通过的 PhoneStateListener 的?

2) is it a bad idea to install a PhoneStateListener within a Service and use it to deliver intents to the Service itself upon the notification of a phone state changed received by the PhoneStateListener?

推荐答案

意图 android.intent.action.SIM_STATE_CHANGED 是广播,当SIM卡状态的变化。例如,在我的HTC Desire采用了T-Mobile的SIM卡,如果我把设备进入飞行模式下意图是广播:

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:

  • 意图:android.intent.action.SIM_STATE_CHANGED与演员:SS = NOT_READY,原因= NULL

如果我再取出来的飞行模式,下面的意图是广播:

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

  • 意图:android.intent.action.SIM_STATE_CHANGED与演员:SS =锁定,原因= PIN
  • 意图:android.intent.action.SIM_STATE_CHANGED与演员:SS = READY,原因= NULL
  • 意图:android.intent.action.SIM_STATE_CHANGED与演员:SS = IMSI,原因= NULL
  • 意图:android.intent.action.SIM_STATE_CHANGED与演员:SS =加载,原因= NULL

有可能的是不同的制造商和型号不同表现不同。正如他们所说,你的情况可能会有所不同。

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

这篇关于如何监控SIM卡状态变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆