我想显示在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*/
}