问题描述
如何检测当GSM信号强度低,蜂窝网络丢失?
有关双SIM卡设备怎么办?
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 your PhoneStateListener
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.
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; SIM卡模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!