android – PhoneStateListener在Phonegap插件中工作吗?

我想在
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);
    }

最佳答案 不推荐使用PhoneStateListener.LISTEN_SIGNAL_STRENGTH.请尝试使用PhoneStateListener.LISTEN_SIGNAL_STRENGTHS ..

点赞