@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_udp_monitor_activity);

    handleTitleDisplay(
        getString(R.string.btn_title_back),
        getString(R.string.str_setting_item_netcheck),
        getString(R.string.btn_clear_all_text));

    mSocketLayer = new UDPSocketUtil();
    tryAgain = (Button) findViewById(R.id.try_again);
    tryAgain.setOnClickListener(this);
    clearBuuton = (Button) findViewById(R.id.clear);
    clearBuuton.setOnClickListener(this);
    udpSend = (TextView) findViewById(R.id.totlesend);
    updReceive = (TextView) findViewById(R.id.totlereceive);
    losebacket = (TextView) findViewById(R.id.lostrate);
    maxDelay = (TextView) findViewById(R.id.maxdelay);
    minDelay = (TextView) findViewById(R.id.mindelay);
    avarageDelay = (TextView) findViewById(R.id.avaragedelay);
    startTimer();

    mSocketLayer.start();
    tryAgain.setEnabled(false);
    clearBuuton.setEnabled(true);
  }
 @Override
 protected void onReceiveBroadcast(Intent intent) {
   super.onReceiveBroadcast(intent);
   if (intent.getAction().equals(SettingsActivity.INTENT_P2P_ENABLED)) {
     addNotificatoinToView(getString(R.string.str_p2p_enable), Gravity.TOP);
   }
 }
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case 1:
       if (timer != null) {
         updateUI(false);
       }
       break;
   }
   super.handleMessage(msg);
 }
  @Override
  protected void onResume() {
    super.onResume();

    if (mLoaclVideoView != null && mLoaclVideoView.getVisibility() == View.VISIBLE) {
      SurfaceView localView = ViERenderer.CreateLocalRenderer(this);
      mLoaclVideoView.addView(localView);
    }

    lockScreen();
  }
 @Override
 protected void handleTitleAction(int direction) {
   if (direction == TITLE_RIGHT_ACTION) {
     mSocketLayer.stop();
     updateUI(true);
     stopTimer();
     tryAgain.setEnabled(true);
     clearBuuton.setEnabled(false);
   } else {
     super.handleTitleAction(direction);
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.layout_voice_verificaode_activity);

    handleTitleDisplay(
        getString(R.string.btn_title_back), getString(R.string.app_title_veri_code), null);

    initResourceRefs();

    RestHelper.getInstance().setOnRestHelperListener(this);
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Log4Util.d(
        VoiceHelper.DEMO_TAG,
        "[VoiceVerificationCodeActivity] onActivityResult: requestCode="
            + requestCode
            + ", resultCode="
            + resultCode
            + ", data="
            + data);

    // If there's no data (because the user didn't select a number and
    // just hit BACK, for example), there's nothing to do.
    if (resultCode != RESULT_OK) {
      Log4Util.d(
          VoiceHelper.DEMO_TAG,
          "[VoiceVerificationCodeActivity] onActivityResult: bail due to resultCode=" + resultCode);
      return;
    }

    int Operating = ValidationStatusActivity.OPERATING_GET_NEW_VERIFY;
    if (data.hasExtra("Operating")) {
      Bundle extras = data.getExtras();
      if (extras != null) {
        Operating = extras.getInt("Operating");
      }
    }

    mVeriCode.getText().clear();
    if (Operating == ValidationStatusActivity.OPERATING_INPUT_AGAIN) {
      mVeriCode.requestFocus();
      requestFocusAndShowInputMode(mVeriCode);
    } else if (Operating == ValidationStatusActivity.OPERATING_GET_NEW_VERIFY) {
      mNumber.getText().clear();
      mNumber.requestFocus();
      requestFocusAndShowInputMode(mNumber);
    } else if (Operating == ValidationStatusActivity.OPERATING_VIEW_OVER) {
      finish();
    } else {
      mNumber.getText().clear();
      mVeriCode.getText().clear();
    }
  }
        @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;
          }
        }
  @Override
  protected void handleTitleAction(int direction) {
    if (direction == TITLE_LEFT_ACTION) {
      // Hang up the video call...
      Log4Util.d(
          VoiceHelper.DEMO_TAG,
          "[VideoActivity] onClick: Voip talk hand up, CurrentCallId " + mCurrentCallId);
      isSelfReject = true;
      try {
        if (mCurrentCallId != null) {
          VoiceHelper.getInstance().getDevice().releaseCall(mCurrentCallId);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      finish();
    } else {

      super.handleTitleAction(direction);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.layout_video_activity);

    handleTitleDisplay(
        getString(R.string.btn_title_back), getString(R.string.app_title_video), null);
    VoiceHelper.getInstance().setHandler(mHandler);
    initResourceRefs();
    initialize();

    cameraInfos = VoiceHelper.getInstance().getDevice().getCameraInfo();

    // Find the ID of the default camera
    if (cameraInfos != null && cameraInfos.length != 0) {
      defaultCameraId = cameraInfos[cameraInfos.length - 1].index;
    }
    VoiceHelper.getInstance().getDevice().selectCamera(defaultCameraId, 0, 15, Rotate.Rotate_Auto);
    mCurrentCallId =
        VoiceHelper.getInstance().getDevice().makeCall(Device.CallType.VIDEO, mVoipAccount);

    registerReceiver(new String[] {SettingsActivity.INTENT_P2P_ENABLED});
  }
        @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;
          }
        }
 @Override
 protected void onPause() {
   super.onPause();
   releaseLockScreen();
 }
 @Override
 protected void onDestroy() {
   super.onDestroy();
 }
 @Override
 protected void onDestroy() {
   super.onDestroy();
   mSocketLayer.stop();
   stopTimer();
 }