本文介绍了当检测到接收返回的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测当接收返回到手机?有意向我可以注册
得到一个消息,当它呢?谢谢

How do I detect when the reception returns to the phone? is there an intent I can registerto get a message when it does? Thanks

推荐答案

样品code:[<一个href=\"http://$c$c.google.com/p/wapdroid/source/browse/trunk/src/com/piusvelte/wapdroid/PhoneListenerApi7.java?r=244\"相对=nofollow>可在这里]

 package com.piusvelte.wapdroid;

    import static com.piusvelte.wapdroid.WapdroidService.PHONE_TYPE_CDMA;
    import static android.telephony.NeighboringCellInfo.UNKNOWN_RSSI;
    import android.telephony.CellLocation;
    import android.telephony.PhoneStateListener;
    import android.telephony.SignalStrength;
    import android.telephony.TelephonyManager;

    // PhoneStateListener for api >= 7
    public class PhoneListenerApi7 extends PhoneStateListener {
            private WapdroidService mService;

            public PhoneListenerApi7(WapdroidService service) {
                    mService = service;
            }

            public void onCellLocationChanged(CellLocation location) {
                    // this also calls signalStrengthChanged, since signalStrengthChanged isn't reliable enough by itself
                    mService.getCellInfo(location);
            }

            public void onSignalStrengthChanged(int asu) {
                    // add cdma support, convert signal from gsm
                    if ((mService.mTeleManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) || (mService.mTeleManager.getPhoneType() == PHONE_TYPE_CDMA)) mService.signalStrengthChanged((asu > 0) && (asu != UNKNOWN_RSSI) ? (2 * asu - 113) : asu);
                    else mService.release();
            }

            public void onSignalStrengthsChanged(SignalStrength signalStrength) {
                    if (mService.mTeleManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
                            int asu = signalStrength.getGsmSignalStrength();
                            mService.signalStrengthChanged((asu > 0) && (asu != UNKNOWN_RSSI) ? (2 * asu - 113) : asu);
                    }
                    else if (mService.mTeleManager.getPhoneType() == PHONE_TYPE_CDMA) mService.signalStrengthChanged(signalStrength.getCdmaDbm() < signalStrength.getEvdoDbm() ? signalStrength.getCdmaDbm() : signalStrength.getEvdoDbm());
                    else mService.release();
            }
    }

这篇关于当检测到接收返回的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 01:03