在Android中啜饮电话

时间:2014-11-13 07:57:30

标签: android sip

当我从我的Android应用程序调用应用程序时,我使用本机sip android我发现了错误 SipAudioCall:sip会话错误:TRANSACTION_TERMINTED:事务已终止 SipAudioCall:onCallEstablished():java.lang.NullPointerException 但呼叫已建立,但在结束通话时它没有给回电

public void initiateCall(final String sipAddress,final IResponse m_listener) {
    this.m_listener = m_listener;

    //m_listener.connectionStatus(sipAddress);

    try {
        SipAudioCall.Listener listener = new SipAudioCall.Listener() {
            @Override
            public void onCallEstablished(SipAudioCall call) {
                //super.onCallEstablished(call);




                call.startAudio();
                call.setSpeakerMode(false);

                if (call.isMuted()) {
                    call.toggleMute();
                }
                //call.toggleMute();
                m_listener.callIsEtsablished(true);

                String useName = call.getPeerProfile().getDisplayName();

                if(useName == null) {
                    Log.d("hamid","useName is null");
                    useName = call.getPeerProfile().getUserName();
                }






            }

            // Much of the client's interaction with the SIP Stack will
            // happen via listeners.  Even making an outgoing m_audioCall, don't
            // forget to set up a listener to set things up once the m_audioCall is established.
           /* @Override
            public void onCallEstablished(SipAudioCall call) {
                //super.onCallEstablished(call);


            }*/
            @Override
            public void onCallEnded(SipAudioCall call) {
                //rejectIncomingCall();
                //m_listener.onCallEndedStatus("Call Ended");
                //m_listener.connectionStatus("Call Ended");
                m_listener.connectionStatus("Ready.");
                m_listener.callIsEtsablished(false);

            }


        };

        m_audioCall = m_manager.makeAudioCall(m_profile.getUriString(), sipAddress, listener, 30);

    }
    catch (Exception e) {
        Log.d("hamid", "Calling exception: "+e);

        Log.i("DialCallActivity/InitiateCall", "Error when trying to close manager.", e);

        if (m_profile != null) {

            try {
                m_manager.close(m_profile.getUriString());

            } catch (Exception ee) {
                Log.i("DialCallActivity/InitiateCall",
                        "Error when trying to close manager.", ee);
                ee.printStackTrace();
            }
        }
        if (m_audioCall != null) {
            m_audioCall.close();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可以尝试添加

call.answerCall(-1); 

在开始音频之前。