Android的SipManager扔NullPointException [英] Android SipManager throwing NullPointException

查看:505
本文介绍了Android的SipManager扔NullPointException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现我自己的Andr​​oid SiP实现,我有我的SIP服务器注册的问题。具体来说,SipManager.register()函数抛出一个NullPointerException异常。有没有人经历过这个?有没有什么是在下面的函数空,所以我不明白的地方这是来自。谢谢

 公共布尔initializeProfile(){
    最终的全局全球= Globals.getInstance();
    如果(sipProfile!= NULL)
        closeLocalProfile();    字符串username =忽略;
    字符串密码=忽略;
    字符串服务器=忽略;    尝试{
        global.Log(试图建立配置文件);
        SipProfile.Builder建设者=新SipProfile.Builder(用户名,
                服务器);
        builder.setPassword(密码);
        sipProfile = builder.build();
        builder.setAutoRegistration(真);        sipManager.open(sipProfile);        思pregistrationListener监听器=新思pregistrationListener(){            公共无效onRegistering(字符串localProfileUri){
                global.Log(SIP Listener-试图注册);
            }            公共无效onRegistrationDone(字符串localProfileUri,
                    长expiryTime){
                global.Log(SIP Listener-注册成功!);
            }            公共无效onRegistrationFailed(字符串localProfileUri,
                    INT错误code,弦乐的errorMessage){
                global.Log(SIP Listener-注册失败);
            }
        };        sipManager.setRegistrationListener(sipProfile.getUriString(),监听器);        //这是在异常被抛出
        sipManager.register(sipProfile,3000,监听器);        如果(sipManager.isRegistered(sipProfile.getUriString()))
        {
            global.Log(SipManager准备调用);
            返回true;
        }
        其他
            返回false;    }赶上(例外前){            global.Log(--- Error-- initializeProfile:+ ex.getMessage());
            返回false;    }}


解决方案

解决我自己的问题。似乎这不工作,而相当不错,在一个线程中运行。

I'm trying to implement my own android sip implementation and I am having problems registering with my SIP server. Specifically, the SipManager.register() function is throwing a NullPointerException. Has anybody experienced this before? There isn't anything that is null in the below function so I don't understand where this is coming from. Thanks

public boolean initializeProfile() {
    final Globals global = Globals.getInstance();
    if (sipProfile != null)
        closeLocalProfile();

    String username = "omitted";
    String password = "omitted";
    String server = "omitted";

    try {
        global.Log("Trying to build the profile");
        SipProfile.Builder builder = new SipProfile.Builder(username,
                server);
        builder.setPassword(password);
        sipProfile = builder.build();


        builder.setAutoRegistration(true);

        sipManager.open(sipProfile);

        SipRegistrationListener listener = new SipRegistrationListener() {

            public void onRegistering(String localProfileUri) {
                global.Log("Sip Listener- Attempting to Register");
            }

            public void onRegistrationDone(String localProfileUri,
                    long expiryTime) {
                global.Log("Sip Listener- Registration Success!");
            }

            public void onRegistrationFailed(String localProfileUri,
                    int errorCode, String errorMessage) {
                global.Log("Sip Listener- Registration Failed");
            }
        };

        sipManager.setRegistrationListener(sipProfile.getUriString(), listener);

        //THIS IS WHERE THE EXCEPTION IS BEING THROWN
        sipManager.register(sipProfile, 3000, listener);

        if (sipManager.isRegistered(sipProfile.getUriString()))
        {
            global.Log("SipManager is ready for calls");
            return true;
        }
        else
            return false;

    } catch (Exception ex) {

            global.Log("---Error-- initializeProfile: " + ex.getMessage());
            return false;

    }

}

解决方案

Solved my own problem. Seems that this doesn't work very well while running in a thread.

这篇关于Android的SipManager扔NullPointException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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