如何检测"无载体QUOT; SIM卡模式? [英] How to detect "no carrier" SIM card mode?
问题描述
如何检测当GSM信号强度低,蜂窝网络丢失?
有关双SIM卡设备怎么办?
Android的:如何检测无载体SIM卡模式
?
块引用>
PhoneStateListener
类是专门设计用于这一目的。当使用它,你可以得到回调时绑定到您目前的供应商GSM信号正在发生变化。请确保您有以下
android.intent.action.PHONE_STATE
在清单文件中设置。接下来,你需要调用
TelephonyManager
并绑定你的PhoneStateListener
来的:TelephonyManager telManager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
telManager.listen(this.phoneListener,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);您可以实现你的
PhoneStateListener
这样:私人最终PhoneStateListener phoneListener =新PhoneStateListener(){ @覆盖
公共无效onSignalStrengthsChanged(SignalStrength signalStrength){
Log.d(onSignalStrengthsChanged,新葛实力
+ signalStrength.getGsmSignalStrength());
}};TS 27.007 8.5
GSM信号强度值在
定义。基本上为0值的低的,31的值是的好的和一个99手段价值的不知道或不检测的。有效值为(0-31,99),如<一说href=\"http://developer.android.com/reference/android/telephony/SignalStrength.html#getGsmSignalStrength%28%29\"相对=nofollow> Android开发者手册。
以上涵盖GSM信号,因此,如果你只对GSM信号兴趣,坚持我的previous例子。如果您可能会感兴趣的陈述是否数据网络的是可用的,由于缺乏信号强度,还可以得到其它信号值,所有可用的数据网络:
- SignalStrength.getCdmaDbm()回报以dBm RSSI值用于CDMA网络。
- SignalStrength.getEvdoDbm()回报以dBm为EVDO网络的RSSI值。
可以知道通过调用<一个什么是当前数据网的类型href=\"http://developer.android.com/reference/android/telephony/TelephonyManager.html#getNetworkType%28%29\"相对=nofollow>
TelephonyManager.getNetworkType()
方法。
有关双SIM卡设备怎么办?
块引用>我不知道,从来没有工作过他们。不过,我不明白为什么上述可能不适用于多SIM卡的设备。它应该是工作本身。
How do I detect when the GSM signal strength is low and the cellular network is lost? What about dual SIM devices?
解决方案Android: how to detect "no carrier" SIM card mode ?
The
PhoneStateListener
class is designed to serve this purpose. When using it, you can get callbacks when the GSM signal bound to your current provider is changing.Make sure you have the following
android.intent.action.PHONE_STATE
set in your manifest file.Next, you'll need to invoke the
TelephonyManager
and bind yourPhoneStateListener
to it :TelephonyManager telManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); telManager.listen(this.phoneListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
You can implement your
PhoneStateListener
as such :private final PhoneStateListener phoneListener = new PhoneStateListener() { @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { Log.d("onSignalStrengthsChanged", "The new singal strength is " + signalStrength.getGsmSignalStrength()); } };
GSM signal strengths values are defined in
TS 27.007 8.5
. Basically a value of 0 is low, a value of 31 is good, and a value of 99 means not known or not detectable. Valid values are (0-31, 99) as stated in the Android Developers manual.The above covers GSM signals, so if you are only interested in GSM signals, stick to my previous example. If you might be interested in stating whether a data network is available or not due to a lack of signal strength, you can also get other signal values for all the available data networks :
- SignalStrength.getCdmaDbm() returns the RSSI value in dBm for CDMA networks.
- SignalStrength.getEvdoDbm() returns the RSSI value in dBm for Evdo networks.
You can know what is the type of the current data network by calling the
TelephonyManager.getNetworkType()
method.What about dual SIM devices ?
I don't know, never worked on them. However I don't see why the above may not be applicable to multi-SIM devices. It should be working as such.
这篇关于如何检测&QUOT;无载体QUOT; SIM卡模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!