简体   繁体   中英

Exception when trying to call(SIP)

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.

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/

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.

检查Android中的网桥连接和应用程序中的SIP服务器,以获取应用程序的SIP密钥。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM