Android VOIP SipException:无法创建SipSession

前端之家收集整理的这篇文章主要介绍了Android VOIP SipException:无法创建SipSession前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我试图在Android 3.1上使用内置SIP运行VOIP呼叫.我有物理平板设备(galaxy Tab 10.1).

出于测试目的,我从SipDemo example创建了一个项目 – 它工作正常! (意思是我的凭据正常,我的设备/网络很好).

我的Manifest.xml

logoeditedsmall" android:label="@string/app_name" android:debuggable="true">
      dio" />

required="true" />
required="true" />
required="true" />

我的后端代码

public void initializeManager() {
    if (manager == null) {
        manager = SipManager.newInstance(this);
    }

    if (me != null) {
        closeLocalProfile();
    }

    try {
        SipProfile.Builder builder = new SipProfile.Builder(username,domain);
        builder.setPassword(password);
        builder.setOutboundProxy(proxy);
        me = builder.build();

        manager.open(me);

        manager.setRegistrationListener(me.getUriString(),new SipRegistrationListener() {

                    @Override
                    public void onRegistering(String localProfileUri) {
                        Log.i("MY","onRegistering");

                    }

                    @Override
                    public void onRegistrationDone(String localProfileUri,long expiryTime) {
                        Log.i("MY","onRegistrationDone");

                    }

                    @Override
                    public void onRegistrationFailed(
                            String localProfileUri,int errorCode,String errorMessage) {
                        Log.i("MY","onRegistrationFailed");

                    }
                });

    } catch (ParseException pe) {
        Log.e("MY",pe.toString());
    } catch (SipException se) {
        Log.e("MY",se.toString());
    }
}



public void initiateCall() {

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

            @Override
            public void onCallEstablished(SipAudioCall call) {
                call.startAudio();
                call.setSpeakerMode(true);
                call.toggleMute();
                Log.i("MY","oonCallEstablished");
            }

            @Override
            public void onCallEnded(SipAudioCall call) {
                Log.i("MY","onCallEnded");
            }
        };

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

    } catch (Exception e) {
        Log.e("MY",e.toString());
        if (me != null) {
            try {
                manager.close(me.getUriString());
            } catch (Exception ee) {
                Log.e("MY",ee.toString());
            }
        }
        if (call != null) {
            call.close();
        }
    }
}

运行此代码(首先我初始化,使用initalizeManager然后我运行initateCall)我收到一个异常:

android.net.sip.SipException: Failed to create SipSession; network unavailable?

…和LogCat日志:

07-14 13:35:16.200: ERROR/SipService(364): openToMakeCalls()
07-14 13:35:16.200: ERROR/SipService(364): javax.sip.SipException: only creator can access the profile
07-14 13:35:16.200: ERROR/SipService(364):     at com.android.server.sip.SipService.createGroup(SipService.java:337)
07-14 13:35:16.200: ERROR/SipService(364):     at com.android.server.sip.SipService.open(SipService.java:185)
07-14 13:35:16.200: ERROR/SipService(364):     at android.net.sip.ISipService$Stub.onTransact(ISipService.java:58)
07-14 13:35:16.200: ERROR/SipService(364):     at android.os.Binder.execTransact(Binder.java:320)
07-14 13:35:16.200: ERROR/SipService(364):     at dalvik.system.NativeStart.run(Native Method)
07-14 13:35:16.200: WARN/SipService(364): only creator can set listener on the profile
07-14 13:35:16.230: WARN/SipService(364): only creator or radio can close this profile

谷歌没有给出任何结果,因为Android 2.3 SIP上没有足够的数据,所以你提出的每个建议都能帮到我很多!

最佳答案
问题解决了:你不能在initializeManager()之后调用initiateCall(). SIP组件初始化后,您必须等待大约4秒钟.

编辑 – SipManager注册似乎仍然存在一些问题:调用用户注册(403).重新安装应用程序并重新启动设备可以解决问题.

原文链接:https://www.f2er.com/android/430455.html

猜你在找的Android相关文章