Exception when trying to call(SIP)

2019-03-27 21:41发布

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.

3条回答
SAY GOODBYE
2楼-- · 2019-03-27 21:52

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

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-03-27 21:57

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.

查看更多
何必那么认真
4楼-- · 2019-03-27 22:19

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/

查看更多
登录 后发表回答