我正在尝试在 Android 的 phonegap 插件中使用 PhoneStateListener 获取 cdma 信号强度。PhoneStateListener 是否在 Phonegap 插件中工作?或者请让我知道我的代码有什么问题。
public void getNetworkSignalStrength()
{
Runnable runnable = new Runnable(){
@Override
public void run() {
// TODO Auto-generated method stub
TelephonyManager phonyManager = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener mListener = new PhoneStateListener(){
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
Log.d("PhoneStateListener", "I am here");
int strengthAmplitude = signalStrength.getCdmaDbm();
cdmaStrength = String.valueOf(strengthAmplitude);
super.onSignalStrengthsChanged(signalStrength);
}
};
phonyManager.listen(mListener,PhoneStateListener.LISTEN_SIGNAL_STRENGTH);
}
};
this.ctx.runOnUiThread(runnable);
}