yangzhenyu
mPhone = (TelephonyManager) this
                .getSystemService(Context.TELEPHONY_SERVICE);
        mPhone.listen(mPhoneStateListener,
                PhoneStateListener.LISTEN_SERVICE_STATE
                        | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
                        | PhoneStateListener.LISTEN_DATA_ACTIVITY);

mPhoneStateListener = new PhoneStateListener() {

        @Override
        public void onDataActivity(int direction) {
            super.onDataActivity(direction);
            Log.v("kevin", "onDataActivity: " + direction);
        }

        @Override
        public void onDataConnectionStateChanged(int state) {
            super.onDataConnectionStateChanged(state);
            if(state == TelephonyManager.DATA_DISCONNECTED){
                Log.v("kevin", "onDataConnectionStateChanged: " + state);
            }
        }

        @Override
        public void onServiceStateChanged(ServiceState serviceState) {
            super.onServiceStateChanged(serviceState);
            Log.v("kevin", "onServiceStateChanged");
        }

    };

分类:

技术点:

相关文章:

  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-10-21
猜你喜欢
  • 2021-07-21
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-06-22
相关资源
相似解决方案