我想在 dbm 中显示信号强度。但是使用我的代码,我总是成为结果-1。但是当我在设置中看到信号强度时,它在 -81 左右。你能找到错误吗?谢谢你!
public class MainActivity extends Activity implements OnClickListener {
TextView dateAndTimeLabel;
private int signalDBM = 0;
public class GetParams extends PhoneStateListener {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
signalDBM = signalStrength.getEvdoDbm();
}
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
GetParams listener = new GetParams();
TelephonyManager TelManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
TelManager.listen(listener ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
Button btn = (Button)findViewById(R.id.start);
btn.setOnClickListener(this);
}
public void onClick(View v) {
Toast.makeText(this, "CDMA signal strength is " + this.signalDBM, Toast.LENGTH_SHORT).show();
}
/* Create options menu etc*/
}