Android SipManager throwing NullPointException

回眸只為那壹抹淺笑 提交于 2019-12-11 18:29:18

问题


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;

    }

}

回答1:


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



来源:https://stackoverflow.com/questions/9687385/android-sipmanager-throwing-nullpointexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!