如何从呼出使用android.net.sip API获取呼叫ID [英] How to get the call Id from an outgoing call using android.net.sip API
问题描述
我想知道如何当你拨出电话使用 android.net.sip
API,你可以得到的呼叫ID。
我目前刚拨出电话,因为他们做在Android SIP演示。
通话= manager.makeAudioCall(me.getUriString(),sipAddress,监听器,30);
我也看到了,你可以为了得到呼叫ID打电话时创建SIP会话的文件中,但我无法弄清楚。请参阅<一href="http://developer.android.com/reference/android/net/sip/SipManager.html#createSipSession(android.net.sip.SipProfile" rel="nofollow">http://developer.android.com/reference/android/net/sip/SipManager.html#createSipSession(android.net.sip.SipProfile有关 SipManager
的说明文件。我也这样做之前,我做音频呼叫:
I am wondering how you can get the call id when you make an outgoing call using the android.net.sip
API.
I am currently just making an outgoing call as they do in the android sip 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 in order 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 the documentation on the SipManager
. I am also doing this before I make the audio 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 being called when I make the outgoing call.
推荐答案
我终于找到了解决问题的方法,在这里它是:
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;
}
而不是使用我们的经理拨打电话的
,我们只是创造我们自己的 SipAudioCall
对象。我们用我们的经理创建一个 SipSession中
,这是我们的方法将用于使我们的 SipAudioCall
对象调用
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.
这篇关于如何从呼出使用android.net.sip API获取呼叫ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!