Exception when trying to call(SIP)

一曲冷凌霜 提交于 2019-12-04 22:51:28

问题


I'm developping a SIP application, and when i want to call someone(with its identifier configured in the server) i have a NullPointerException => "Error when trying to close manager." Here is the code:

public void initiateCall() {

        updateStatus(sipAddress);

        try {
            SipAudioCall.Listener listener = new SipAudioCall.Listener() {

                @Override
                public void onCallEstablished(SipAudioCall call) {
                    call.startAudio();
                    call.setSpeakerMode(true);
                    call.toggleMute();
                    updateStatus(call);
                }

                @Override
                public void onCallEnded(SipAudioCall call) {
                    updateStatus("Ready.");
                }
            };

            call = manager.makeAudioCall(me.getUriString(), sipAddress, listener, 30);

        }
        catch (Exception e) {
            Log.i("WalkieTalkieActivity/InitiateCall", "Error when trying to close manager.", e);
            if (me != null) {
                try {
                    manager.close(me.getUriString());
                } catch (Exception ee) {
                    Log.i("WalkieTalkieActivity/InitiateCall",
                            "Error when trying to close manager.", ee);
                    ee.printStackTrace();
                }
            }
            if (call != null) {
                call.close();
            }
        }
    }

Thank you for your help.


回答1:


The VOIP/SIP libary is not supported by default on Android emulator. The problem is that the
manager == null - thats why you are getting the NullPointerException.

Luckily, there is a work-a-round. Download this link and copy it into ...\.android\avd\.avd folder.

Start your emulator and

 Boolean voipSupported = SipManager.isVoipSupported(this);
 Boolean apiSupported = SipManager.isApiSupported(this);

should now return true.

Source: http://xilard.hu/




回答2:


Android.net.sip (Sip API) only works on G711 over Android 2.3+. Also the phones supplied by carriers may have the SIP stack (android.net.sip) blocked or cripple. SipManager.isVoipSupported(this) && SipManager.isApiSupported(this) will return false for most of the devices is your ie. your SipManager object will always be null in such case.You should use third party library to implement SIP.

There are different open source sip stack libraries as well as projects are available on internet. You can download the source code of that projects. Here is the List of some popular open source sip stack libraries which allows to voice call over internet.

1.Jain sip (I think the best option):

2.Pjsip

3.Mjsip

4.Doubango

There are different open source projects which have used these libraries in their projects.

1.Jain sip: Not used in a "famous" app. 2. Sipdroid uses MjSip 3. Csipsimple uses PjSip 4. Imsdroid uses doubango.




回答3:


Check the bridge connection in Android and the SIP server in your application to obtain the SIP key of your application.



来源:https://stackoverflow.com/questions/5771236/exception-when-trying-to-callsip

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