Android的VOIP SipException:无法创建SipSession中 [英] Android VOIP SipException: Failed to create SipSession

查看:625
本文介绍了Android的VOIP SipException:无法创建SipSession中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着去运行一个VOIP呼叫使用内置的SIP在Android 3.1。我有物理平板电脑(Galaxy Tab的10.1)。

Im trying to run a VOIP call using built in SIP on android 3.1. I have physical tablet device (galaxy Tab 10.1).

有关测试目的,我创建了一个项目从 SipDemo例如 - 它工作正常! (意为我的凭据正在和我的设备/网络是罚款)。

For testing purpose, I have created a project from SipDemo example - it works fine! (meaning my credentials are working and my device/network is fine).

我的Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="modera.com.doorcontroller" android:versionCode="1" android:versionName="1.0">

    <application android:icon="@drawable/logoeditedsmall" android:label="@string/app_name" android:debuggable="true">
      <activity android:name="MainActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>

      <activity android:name="CallActivity"></activity>

</application>

<uses-sdk android:minSdkVersion="11" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_SIP" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-feature android:name="android.hardware.sip.voip" android:required="true" />
<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-feature android:name="android.hardware.microphone" android:required="true" />

</manifest>

我的后端code:

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();
        }
    }
}

运行此code(起初我initalize,使用initalizeManager然后我跑initateCall)我收到一个异常:

Running this code (at first I initalize, using initalizeManager and then I run initateCall) I receive an exception:

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

...和LogCat中日志:

...and LogCat logs:

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,让每一个建议你让帮助了我很多!

Google hasn't given any results, because there just isnt enough data on Android 2.3+ SIP, so every suggestion you make helps me out a lot!

推荐答案

问题解决了::你不能调用initiateCall()后initializeManager右()。你必须等待约4秒时SIP组件已初始化。

Problem solved: You can not call initiateCall() right after initializeManager(). You have to wait about 4 seconds when the SIP components have initialized.

编辑 - 的存在似乎还是有些问题SipManager登记:主叫用户未注册(403)。重新安装应用程序,并重新启动设备解决了这个问题。

EDIT- there seems to be still be some problem with SipManager registering: Calling User Not registered (403). Reinstalling app and rebooting device solves the problem.

这篇关于Android的VOIP SipException:无法创建SipSession中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆