How to get call id from outgoing call using android.net.sip API

I am wondering how you can get the call id when making an outbound call using the API android.net.sip

. Currently I am just making an outgoing call like in the sroid demo. call = manager.makeAudioCall(me.getUriString(), sipAddress, listener, 30);


I also saw in the documentation that you can create a sip session when making a call to get the call id, but I just can't figure it out. See http://developer.android.com/reference/android/net/sip/SipManager.html#createSipSession(android.net.sip.SipProfile for documentation on SipManager

. I also do this before making a sound call:

manager.createSipSession(me, new SipSession.Listener(){
        @Override
        public void onCalling(SipSession session) {
            String callId = session.getCallId();
            Log.d(TAG, "onCalling. call ID: " + callId);
        }
        @Override
        public void onRingingBack(SipSession session) {
            String callId = session.getCallId();
            Log.d(TAG, "onRinging. call ID!!!: " + callId);
        }
        @Override
        public void onCallEstablished(SipSession session,
                String sessionDescription) {
            String callId = session.getCallId();
            Log.d(TAG, "onCallEstablished: call ID!!!: " + callId);

        }

    });

      

but none of the methods are called when I make an outgoing call.

0


source to share


1 answer


Finally I 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 calling with our manager, we just create our own SipAudioCall

object. We are using our create manager SipSession

, which we will use in the method to make a call to our object SipAudioCall

.

0


source







All Articles