public void handleMessage(Message msg) {
   switch (msg.what) {
     case 1:
       if (timer != null) {
         updateUI(false);
       }
       break;
   }
   super.handleMessage(msg);
 }
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);

          ERequestState reason = ERequestState.Failed;
          // 获取通话ID
          if (msg.obj instanceof ERequestState) {
            reason = (ERequestState) msg.obj;
          }

          switch (msg.what) {
              // receive a new voice mail messages...
            case VoiceHelper.WHAT_ON_VERIFY_CODE:
              if (reason == ERequestState.Success) {
                Toast.makeText(
                        VoiceVerificationCodeActivity.this, "获取验证码成功,请等待系统来电", Toast.LENGTH_SHORT)
                    .show();
                mCodeBtn.setEnabled(false);
                new CountDownTimer(30000, 1000) {

                  @Override
                  public void onTick(long millisUntilFinished) {
                    mCodeBtn.setText(
                        getString(R.string.str_verify_code_timer, millisUntilFinished / 1000));
                  }

                  @Override
                  public void onFinish() {
                    mCodeBtn.setText(getString(R.string.str_get_verify_code));
                    mCodeBtn.setEnabled(true);
                  }
                }.start();
              } else {
                Toast.makeText(
                        VoiceVerificationCodeActivity.this, "获取验证码失败,请重试", Toast.LENGTH_SHORT)
                    .show();
              }
              break;

            default:
              break;
          }
        }
Пример #3
0
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);
          String callid = null;
          Reason reason;
          Bundle b = null;
          // 获取通话ID
          if (msg.obj instanceof String) {
            callid = (String) msg.obj;
          } else if (msg.obj instanceof Bundle) {
            b = (Bundle) msg.obj;
            callid = b.getString(Device.CALLID);
          }
          switch (msg.what) {
            case VoiceHelper.WHAT_ON_CALL_ALERTING:
              // 连接到对端用户,播放铃音
              Log4Util.d(VoiceHelper.DEMO_TAG, "[VideoActivity] handleMessage: voip alerting!!");
              if (callid != null && mCurrentCallId.equals(callid)) { // 等待对方接受邀请...
                mVideoCallTips.setText(getString(R.string.str_tips_wait_invited));
              }
              break;
            case VoiceHelper.WHAT_ON_CALL_PROCEEDING:
              // 连接到服务器
              Log4Util.d(
                  VoiceHelper.DEMO_TAG, "[VideoActivity] handleMessage: voip on call proceeding!!");
              if (callid != null && mCurrentCallId.equals(callid)) {
                mVideoCallTips.setText(getString(R.string.voip_call_connect));
              }
              break;
            case VoiceHelper.WHAT_ON_CALL_ANSWERED:
              // 对端应答
              Log4Util.d(
                  VoiceHelper.DEMO_TAG, "[VideoActivity] handleMessage: voip on call answered!!");
              if (callid != null && mCurrentCallId.equals(callid) && !isConnect) {
                initResVideoSuccess();
                if (mHandler != null) {
                  //
                  // mHandler.sendMessage(mHandler.obtainMessage(WHAT_ON_CODE_CALL_STATUS));
                }
              }
              break;

            case VoiceHelper.WHAT_ON_CALL_RELEASED:
              // 远端挂断,本地挂断在onClick中处理
              Log4Util.d(
                  VoiceHelper.DEMO_TAG, "[VideoActivity] handleMessage: voip on call released!!");
              if (callid != null && mCurrentCallId.equals(callid) && !isSelfReject) {
                finishCalling();
              }
              break;
            case VoiceHelper.WHAT_ON_CALL_MAKECALL_FAILED:
              // 发起通话失败
              Log4Util.d(
                  VoiceHelper.DEMO_TAG,
                  "[VideoActivity] handleMessage: voip on call makecall failed!!");
              if (b != null && b.get(Device.REASON) != null) {
                reason = (Reason) b.get(Device.REASON);
                if (callid != null && mCurrentCallId.equals(callid) && !isSelfReject) {
                  finishCalling(reason);
                }
              }
              break;
            case WHAT_ON_CODE_CALL_STATUS:
              CallStatisticsInfo callStatistics =
                  VoiceHelper.getInstance().getDevice().getCallStatistics(Device.CallType.VIDEO);
              if (callStatistics != null) {
                int fractionLost = callStatistics.getFractionLost();
                int rttMs = callStatistics.getRttMs();
                mCallStatus.setText(getString(R.string.str_call_status, fractionLost, rttMs));
              }
              if (isConnect && mHandler != null) {
                Message callMessage = mHandler.obtainMessage(WHAT_ON_CODE_CALL_STATUS);
                mHandler.sendMessageDelayed(callMessage, 4000);
              }
              break;
            default:
              break;
          }
        }