[Linphone Android] 登录实现

Linphone的登录并非直接调用LinphoneCore的addAuthInfo就可以,而是需要做一些配置的设定:

public int login(String strName, String strPassword, String strDomain) throws LinphoneCoreException{

        String strIdetify = "sip:" + strName + "@" + strDomain;

        if (strPassword != null) {
            // create authentication structure from identity and add to core
            mLinphoneCore.addAuthInfo(LinphoneCoreFactory.instance().createAuthInfo(strName, strPassword, null, strDomain));
        }

        LinphoneProxyConfig proxyCfg = mLinphoneCore.createProxyConfig(strIdetify, strDomain, null, true);
        proxyCfg.setExpires(2000);
        mLinphoneCore.addProxyConfig(proxyCfg);
        mLinphoneCore.setDefaultProxyConfig(proxyCfg);

        mLinphoneCore.getDefaultProxyConfig().edit();
        mLinphoneCore.getDefaultProxyConfig().enableRegister(false);
        mLinphoneCore.getDefaultProxyConfig().done();

        mLinphoneCore.getDefaultProxyConfig().edit();
        mLinphoneCore.getDefaultProxyConfig().enableRegister(true);
        mLinphoneCore.getDefaultProxyConfig().done();


        return 0;
    }

你可能感兴趣的:(android,登录,login,linphone)