How to get the call Id from an outgoing call using android.net.sip API

时光怂恿深爱的人放手 提交于 2019-12-04 21:14:23

I finally found a solution to the problem, and here it is:

private SipAudioCall myMakeAudioCall(Context context, SipProfile sipProfile, SipProfile peerProfile, int timeout) throws SipException{

    SipAudioCall.Listener l = new SipAudioCall.Listener(){
        @Override
        public void onCallEstablished(SipAudioCall call) {
        }
        //add more methods if you want to
    };

    SipAudioCall testCall = new SipAudioCall(context,sipProfile);
    testCall.setListener(l);

    SipSession.Listener sessionListener = new SipSession.Listener(){
        @Override
        public void onCalling(SipSession session) {
            String callId = session.getCallId();
            Log.d(TAG, "onCalling. call ID: " + callId);
        }
        //add more methods if you want to
    };

    SipSession ss = manager.createSipSession(sipProfile, sessionListener);
    if(ss == null){
        throw new SipException("Failed to create SipSession; Network available?");
    }
    testCall.makeCall(peerProfile, ss, timeout);
    Log.d(TAG,"iD: " + ss.getCallId());
    return testCall;
}

Instead of making a call using our manager, we simply create our own SipAudioCall object. We use our manager to create a SipSession, which we will use in the method for making a call with our SipAudioCall object.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!