公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

本文介绍了Android SipManager:android.net.sip.SipException:SipService.createSession()返回空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我使用androids sip库编写这个android sip应用程序已经有一段时间了,但我无法进行注册。目前,我调用SipManager.register()时出现以下错误:android.net.sip.SipException: SipService.createSession() returns null。

我的代码:

public static void Register(final String username, final String password, final String domain, final String cbf)
        throws ParseException, SipException {

    Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register");
    /*
     * Luodaan SIP-profiili
     */
    SipProfile.Builder builder = new SipProfile.Builder(username, domain);
    builder.setPassword(password);
    //builder.setProtocol("TCP");
    //builder.setPort(5060);
    builder.setAutoRegistration(false);
    _sipprofile = builder.build();

    Intent intent = new Intent();
    intent.setAction("android.jahtipuhelin.INCOMING_CALL");
    PendingIntent pendingIntent = PendingIntent.getBroadcast(_context, 0, intent, Intent.FILL_IN_DATA);
    _sipmanager.open(_sipprofile, pendingIntent, new SipRegistrationListener() {
        @Override
        public void onRegistering(String s) {
            Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 0");

        }

        @Override
        public void onRegistrationDone(String s, long l) {
            Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 1");

            try {
                _sipmanager.register(_sipprofile, 30, null);
                _sipmanager.setRegistrationListener(_sipprofile.getUriString(),  new JPSipRegistrationListener(_class, cbf));
            } catch (SipException e) {
                Log.e(MainActivity.LOGTAG,e.getClass().toString()+ ": "+ e.getMessage());
                e.printStackTrace();
            }
        }

        @Override
        public void onRegistrationFailed(String s, int i, String s2) {
            Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - testi 2");
            Log.d(MainActivity.LOGTAG, s2);

            try {

                _sipmanager.register(_sipprofile, 30, null);
                _sipmanager.setRegistrationListener(_sipprofile.getUriString(),  new JPSipRegistrationListener(_class, cbf));
            } catch (SipException e) {
                Log.e(MainActivity.LOGTAG,e.getClass().toString()+ ": "+ e.getMessage());
                e.printStackTrace();
            }
        }
    });//*/

    Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.Register - 2");
}


private static class JPSipRegistrationListener implements SipRegistrationListener {
    private MainActivity _parent;
    private String _callBack;

    public JPSipRegistrationListener(MainActivity ma, String callBack) {
        this._parent = ma;
        this._callBack = callBack;
    }

    @Override
    public void onRegistering(String localProfileUri) {
        Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistering");
        _parent.callSub(_callBack, REGISTERING, 0, "");
    }

    @Override
    public void onRegistrationDone(String localProfileUri, long expiryTime) {
        Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistrationDone");

        _parent.callSub(_callBack, REGISTRATION_DONE, 0, "");
    }

    @Override
    public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) {
        Log.d(MainActivity.LOGTAG, "testi: JahtipuhelinSipManager.onRegistrationFailed");

        Log.e(MainActivity.LOGTAG, "Virhe Sip-rekisteröinnissä: "+errorCode+": "+errorMessage);
        if (errorCode == -10) {
            return;
        }
        _parent.callSub(_callBack, REGISTRATION_FAILED, errorCode, errorMessage);
    }

}

运行该命令将产生以下输出:

08-11 18:50:58.276  24449-24449/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register
08-11 18:50:58.436  24449-24465/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register - testi 2
08-11 18:50:58.436  24449-24465/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: registration not running
08-11 18:50:58.446  24449-24449/fi.hieta.aatu.android.jahtipuhelin D/fi.hieta.aatu.android.jahtipuhelin: testi: JahtipuhelinSipManager.Register - 2
08-11 18:50:58.666  24449-24465/fi.hieta.aatu.android.jahtipuhelin E/fi.hieta.aatu.android.jahtipuhelin: class android.net.sip.SipException: SipService.createSession() returns null

有人知道我做错了什么吗?此外,我正在尝试手动注册sip配置文件,而不是使用自动注册。(顺便提一下我关于堆栈溢出的第一个问题,所以请轻一点:))

推荐答案

似乎至少有另一个异常导致相同的错误代码。如果您的手机上碰巧有一个预定义的帐户,并且具有相同的请求URI,那么您试图在您的应用程序中创建的第二个帐户就会以这种方式失败。请注意,即使没有为来电设置该帐户(=后端中的SIP注册),也会发生这种情况。
我希望Android团队能够修复这个错误,或者至少抛出一个有意义的错误。

这篇关于Android SipManager:android.net.sip.SipException:SipService.createSession()返回空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,

分享到:
标签:Android createSession net SipManager SipService 返回
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定