4

我正在尝试在 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);
    }
4

1 回答 1

2

PhoneStateListener.LISTEN_SIGNAL_STRENGTH 已弃用。请尝试使用 PhoneStateListener.LISTEN_SIGNAL_STRENGTHS..

于 2012-08-09T19:14:26.997 回答