通话功能

本文介绍与 Linkus Android SDK 通话相关的功能及实现方法。

发起呼叫

/**
 *
 * @param callNumber:被叫号码
 * @param netWorkAvailable:网络是否可用;true:可用,false:不可用
 * @return
 */
public void makeNewCall(String callNumber, boolean netWorkAvailable)
//调用方式如下
        YlsCallManager.getInstance().makeNewCall(number, netWorkAvailable);

接听来电

YlsCallManager.getInstance().answerCall(callId);

拒接来电

YlsCallManager.getInstance().answerBusy(context, callId);

挂断通话

YlsCallManager.getInstance().hangUpCall(context, callId);

保持通话

YlsCallManager.getInstance().holdCall(inCallVo);

恢复通话

YlsCallManager.getInstance().unHoldCall(getContext(), inCallVo);

咨询转接通话

发起咨询转接
YlsCallManager.getInstance().makeTransferCall(context, calleeName, number, trunkName, route, object);
确认咨询转接
YlsCallManager.getInstance().confirmTransfer(App.getInstance().getContext());

盲转接通话

YlsCallManager.getInstance().blindTransferCall(context, callOutNumber);

静音 / 取消静音通话

/**
 * @param inCallVo
 */
public void mute(InCallVo inCallVo)

通话录音

/**
 *
 * @param vo
 * @return
 */
public int record(InCallVo vo)

发送 DTMF

/**
 *
 * @param callId
 * @param recordCode
 * @return
 */
public int sendDtmf(int callId, String recordCode)

通话质量检测

CallQualityVo callQualityVo = YlsCallManager.getInstance().getCallQuality();

通话状态回调

YlsCallManager.getInstance().setCallStateCallback(new CallStateCallback() {
//通话状态变化回调
@Override
public void onCallStateChange(CallStateVo callStateVo) {
        EventBus.getDefault().post(new CallStateEvent(callStateVo));
        }

//通话质量等级变化回调
@Override
public void onNetWorkLevelChange(int callId, int networkLevel) {
        EventBus.getDefault().postSticky(new NetWorkLevelEvent(callId, networkLevel));
        }

//网络连接变化回调
@Override
public void onConnectChange() {
        EventBus.getDefault().postSticky(new ConnectionChangeEvent());
        }

//录音状态变化回调
@Override
public void onRecordChange(boolean isRecording) {
        EventBus.getDefault().post(new RecordEvent(isRecording));
        }

        });

通话 UI 界面回调

YlsCallManager.getInstance().setActionCallback(new ActionCallback() {

//通话结束回调
@Override
public void onFinishCall() {
        finishAllCall(context);
        }

//来电弹窗回调
@Override
public void onNewCall() {
        jump2CallActivity(context);
        }

//来电等待回调
@Override
public void onCallWaiting() {
        EventBus.getDefault().post(new CallWaitingEvent());
        SoundManager.getInstance().startPlay(context, YlsConstant.SOUND_CALL_WAITING_TYPE);
        }

//未接来电回调
@Override
public void onMissCallClick() {

        }

//通话结束后停止前台服务的回调 (Android 11 以上的通话在后台运行时,需要开启前台服务)
@Override
public void onStopMicroPhoneService() {

        }

//音频路由弹窗消失回调
@Override
public void onDismissPopupView() {
        dismissPopupView();
        }

//音频路由变更回调
@Override
public void onNotifyAudioChange() {
        notifyAudioChange();
        }
        });