@Override
 protected void onDestroy() {
   super.onDestroy();
   try {
     callHelper.setSurfaceView(null);
     cameraHelper.stopCapture();
     oppositeSurface = null;
     cameraHelper = null;
   } catch (Exception e) {
   }
 }
 @Override
 protected void onDestroy() {
   DemoHelper.getInstance().isVideoCalling = false;
   stopMonitor();
   try {
     callHelper.setSurfaceView(null);
     cameraHelper.stopCapture();
     oppositeSurface = null;
     cameraHelper = null;
   } catch (Exception e) {
   }
   super.onDestroy();
 }
示例#3
0
  @Override
  public void onAttach(Activity activity) {
    super.onAttach(activity);
    isAttached = true;

    if (activity instanceof MainActivity) {
      ((MainActivity) activity).updateStatusFragment(this);
      isInCall = false;
    } else if (activity instanceof CallActivity) {
      ((CallActivity) activity).updateStatusFragment(this);
      isInCall = true;
    } else if (activity instanceof AssistantActivity) {
      //			((AssistantActivity) activity).updateStatusFragment(this);
      isInCall = false;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
      finish();
      return;
    }
    setContentView(R.layout.activity_video_call);

    getWindow()
        .addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    callStateTextView = (TextView) findViewById(R.id.tv_call_state);
    comingBtnContainer = (LinearLayout) findViewById(R.id.ll_coming_call);
    rootContainer = (RelativeLayout) findViewById(R.id.root_layout);
    refuseBtn = (Button) findViewById(R.id.btn_refuse_call);
    answerBtn = (Button) findViewById(R.id.btn_answer_call);
    hangupBtn = (Button) findViewById(R.id.btn_hangup_call);
    muteImage = (ImageView) findViewById(R.id.iv_mute);
    handsFreeImage = (ImageView) findViewById(R.id.iv_handsfree);
    callStateTextView = (TextView) findViewById(R.id.tv_call_state);
    nickTextView = (TextView) findViewById(R.id.tv_nick);
    chronometer = (Chronometer) findViewById(R.id.chronometer);
    voiceContronlLayout = (LinearLayout) findViewById(R.id.ll_voice_control);
    btnsContainer = (RelativeLayout) findViewById(R.id.ll_btns);
    topContainer = (LinearLayout) findViewById(R.id.ll_top_container);
    bottomContainer = (LinearLayout) findViewById(R.id.ll_bottom_container);

    refuseBtn.setOnClickListener(this);
    answerBtn.setOnClickListener(this);
    hangupBtn.setOnClickListener(this);
    muteImage.setOnClickListener(this);
    handsFreeImage.setOnClickListener(this);
    rootContainer.setOnClickListener(this);

    msgid = UUID.randomUUID().toString();
    // 获取通话是否为接收方向的
    isInComingCall = getIntent().getBooleanExtra("isComingCall", false);
    username = getIntent().getStringExtra("username");

    // 设置通话人
    nickTextView.setText(username);

    // 显示本地图像的surfaceview
    localSurface = (SurfaceView) findViewById(R.id.local_surface);
    localSurface.setZOrderMediaOverlay(true);
    localSurface.setZOrderOnTop(true);
    localSurfaceHolder = localSurface.getHolder();

    // 获取callHelper,cameraHelper
    callHelper = EMVideoCallHelper.getInstance();
    cameraHelper = new CameraHelper(callHelper, localSurfaceHolder);

    // 显示对方图像的surfaceview
    oppositeSurface = (SurfaceView) findViewById(R.id.opposite_surface);
    oppositeSurfaceHolder = oppositeSurface.getHolder();
    // 设置显示对方图像的surfaceview
    callHelper.setSurfaceView(oppositeSurface);

    localSurfaceHolder.addCallback(new localCallback());
    oppositeSurfaceHolder.addCallback(new oppositeCallback());

    // 设置通话监听
    addCallStateListener();

    if (!isInComingCall) { // 拨打电话
      soundPool = new SoundPool(1, AudioManager.STREAM_RING, 0);
      outgoing = soundPool.load(this, R.raw.outgoing, 1);

      comingBtnContainer.setVisibility(View.INVISIBLE);
      hangupBtn.setVisibility(View.VISIBLE);
      String st = getResources().getString(R.string.Are_connected_to_each_other);
      callStateTextView.setText(st);

      handler.postDelayed(
          new Runnable() {
            public void run() {
              streamID = playMakeCallSounds();
            }
          },
          300);
    } else { // 有电话进来
      voiceContronlLayout.setVisibility(View.INVISIBLE);
      localSurface.setVisibility(View.INVISIBLE);
      Uri ringUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
      audioManager.setMode(AudioManager.MODE_RINGTONE);
      audioManager.setSpeakerphoneOn(true);
      ringtone = RingtoneManager.getRingtone(this, ringUri);
      ringtone.play();
    }
  }
示例#5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
      finish();
      return;
    }
    setContentView(R.layout.activity_voice_call);

    HXSDKHelper.getInstance().isVoiceCalling = true;
    comingBtnContainer = (LinearLayout) findViewById(R.id.ll_coming_call);
    refuseBtn = (Button) findViewById(R.id.btn_refuse_call);
    answerBtn = (Button) findViewById(R.id.btn_answer_call);
    hangupBtn = (Button) findViewById(R.id.btn_hangup_call);
    muteImage = (ImageView) findViewById(R.id.iv_mute);
    handsFreeImage = (ImageView) findViewById(R.id.iv_handsfree);
    userImage = (ImageView) findViewById(R.id.swing_card);
    callStateTextView = (TextView) findViewById(R.id.tv_call_state);
    nickTextView = (TextView) findViewById(R.id.tv_nick);
    durationTextView = (TextView) findViewById(R.id.tv_calling_duration);
    chronometer = (Chronometer) findViewById(R.id.chronometer);
    voiceContronlLayout = (LinearLayout) findViewById(R.id.ll_voice_control);

    refuseBtn.setOnClickListener(this);
    answerBtn.setOnClickListener(this);
    hangupBtn.setOnClickListener(this);
    muteImage.setOnClickListener(this);
    handsFreeImage.setOnClickListener(this);

    getWindow()
        .addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    // 注册语音电话的状态的监听
    addCallStateListener();
    msgid = UUID.randomUUID().toString();

    username = getIntent().getStringExtra("username");
    // 语音电话是否为接收的
    isInComingCall = getIntent().getBooleanExtra("isComingCall", false);
    //  设置通话人头像
    UserUtils.setUserAvatar(this, username, userImage);
    // 设置通话人
    /** 根据usename匹配本地好友获得昵称 */
    FriendDao friendDao = new FriendDao(this);
    Friend friend = friendDao.getFriend(username);
    nickTextView.setText(friend.getTitle());
    if (!isInComingCall) { // 拨打电话
      soundPool = new SoundPool(1, AudioManager.STREAM_RING, 0);
      outgoing = soundPool.load(this, R.raw.outgoing, 1);

      comingBtnContainer.setVisibility(View.INVISIBLE);
      hangupBtn.setVisibility(View.VISIBLE);
      st1 = getResources().getString(R.string.Are_connected_to_each_other);
      callStateTextView.setText(st1);
      handler.postDelayed(
          new Runnable() {
            public void run() {
              streamID = playMakeCallSounds();
            }
          },
          300);
      try {
        // 拨打语音电话
        EMChatManager.getInstance().makeVoiceCall(username);
      } catch (EMServiceNotReadyException e) {
        e.printStackTrace();
        final String st2 = getResources().getString(R.string.Is_not_yet_connected_to_the_server);
        runOnUiThread(
            new Runnable() {
              public void run() {
                Toast.makeText(VoiceCallActivity.this, st2, Toast.LENGTH_SHORT).show();
              }
            });
      }
    } else { // 有电话进来
      voiceContronlLayout.setVisibility(View.INVISIBLE);
      Uri ringUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
      audioManager.setMode(AudioManager.MODE_RINGTONE);
      audioManager.setSpeakerphoneOn(true);
      ringtone = RingtoneManager.getRingtone(this, ringUri);
      ringtone.play();
    }
  }
示例#6
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   HXSDKHelper.getInstance().isVoiceCalling = false;
 }
示例#7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
      finish();
      return;
    }
    setContentView(R.layout.em_activity_voice_call);
    StatusBarUtil.setColor(this, R.color.colorPrimary);
    EaseUI.getInstance().isVoiceCalling = true;
    callType = 0;

    comingBtnContainer = (LinearLayout) findViewById(R.id.ll_coming_call);
    refuseBtn = (Button) findViewById(R.id.btn_refuse_call);
    answerBtn = (Button) findViewById(R.id.btn_answer_call);
    hangupBtn = (Button) findViewById(R.id.btn_hangup_call);
    muteImage = (ImageView) findViewById(R.id.iv_mute);
    handsFreeImage = (ImageView) findViewById(R.id.iv_handsfree);
    callStateTextView = (TextView) findViewById(R.id.tv_call_state);
    nickTextView = (TextView) findViewById(R.id.tv_nick);
    durationTextView = (TextView) findViewById(R.id.tv_calling_duration);
    chronometer = (Chronometer) findViewById(R.id.chronometer);
    voiceContronlLayout = (LinearLayout) findViewById(R.id.ll_voice_control);
    netwrokStatusVeiw = (TextView) findViewById(R.id.tv_network_status);
    iv_avatar = (ImageView) findViewById(R.id.iv_avatar);
    refuseBtn.setOnClickListener(this);
    answerBtn.setOnClickListener(this);
    hangupBtn.setOnClickListener(this);
    muteImage.setOnClickListener(this);
    handsFreeImage.setOnClickListener(this);

    getWindow()
        .addFlags(
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    // 注册语音电话的状态的监听
    addCallStateListener();
    msgid = UUID.randomUUID().toString();

    username = getIntent().getStringExtra("username");
    // 语音电话是否为接收的
    isInComingCall = getIntent().getBooleanExtra("isComingCall", false);

    // 设置通话人
    nickTextView.setText(User.getCurrentUser(User.class).getLoverNick());

    Glide.with(this)
        .load(User.getCurrentUser(User.class).getLoverAvatar())
        .crossFade()
        .bitmapTransform(new CropCircleTransformation(this))
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(iv_avatar);
    if (!isInComingCall) { // 拨打电话
      soundPool = new SoundPool(1, AudioManager.STREAM_RING, 0);
      outgoing = soundPool.load(this, R.raw.em_outgoing, 1);

      comingBtnContainer.setVisibility(View.INVISIBLE);
      hangupBtn.setVisibility(View.VISIBLE);
      st1 = getResources().getString(R.string.Are_connected_to_each_other);
      callStateTextView.setText(st1);
      handler.sendEmptyMessage(MSG_CALL_MAKE_VOICE);
    } else { // 有电话进来
      voiceContronlLayout.setVisibility(View.INVISIBLE);
      Uri ringUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
      audioManager.setMode(AudioManager.MODE_RINGTONE);
      audioManager.setSpeakerphoneOn(true);
      ringtone = RingtoneManager.getRingtone(this, ringUri);
      ringtone.play();
    }
  }