本帖最后由 xingao0113 于 2010-01-21 12:24:04 编辑

解决方案 »

  1.   

    电池状态可以监听ACTION_BATTERY_CHANGED广播,但是信号状态貌似没有相应广播
      

  2.   

    http://bbs.android123.com/thread-4018-1-1.html
      

  3.   

    package lab.sodino.singal;import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.telephony.PhoneStateListener;
    import android.telephony.SignalStrength;
    import android.telephony.TelephonyManager;
    import android.widget.ScrollView;
    import android.widget.Scroller;
    import android.widget.TextView;
    import android.widget.Toast;public class SingalAct extends Activity {
    private TextView textView;
    private TelephonyManager telMag;
    private MyPhoneStateListener phoneLis; /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    textView = new TextView(this);
    textView.setText("start...\n");
    ScrollView scrollView = new ScrollView(this);
    scrollView.addView(textView);
    setContentView(scrollView);
    phoneLis = new MyPhoneStateListener();
    telMag = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    telMag.listen(phoneLis, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    textView.append("NetworkCountryIso=" + telMag.getNetworkCountryIso()
    + "\n");
    textView
    .append("NetworkOperator=" + telMag.getNetworkOperator() + "\n");
    textView.append("NetworkOperatorName="
    + telMag.getNetworkOperatorName() + "\n");
    textView.append("NetworkType=" + telMag.getNetworkType() + "\n");
    } public void onPause() {
    super.onPause();
    telMag.listen(phoneLis, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    } public void onResume() {
    super.onResume();
    telMag.listen(phoneLis, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
    } private class MyPhoneStateListener extends PhoneStateListener {
    private int lastStrength = 0; public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    super.onSignalStrengthsChanged(signalStrength);
    lastStrength = signalStrength.getGsmSignalStrength();
    textView.append("SignalQuality=" + lastStrength + "\n");
    } /** 获取上一次变化到现在的信号强度值。 */
    public int getLastStrength() {
    return lastStrength;
    }
    }
    }
    主动获取调用:getLastStrength()这也是一个折中的方法吧