1

如何配置我的 SIP 帐户。我的项目卡在这里,因为 SIP 的配置没有完成。
这是我的项目类的一个方法。我也可以在这里使用端口号吗?或者我做什么?

public void initializeLocalProfile() {
    if (manager == null) {
        return;
    }

    if (me != null) {
        closeLocalProfile();
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String username = prefs.getString("namePref", "");
    String domain = prefs.getString("domainPref", "");
    String password = prefs.getString("passPref", "");

    if (username.length() == 0 || domain.length() == 0 || password.length() == 0) {
        showDialog(UPDATE_SETTINGS_DIALOG);
        return;
    }

    try {
        SipProfile.Builder builder = new SipProfile.Builder(username, domain);
        builder.setPassword(password);
        me = builder.build();

        Intent i = new Intent();
        i.setAction("android.SipDemo.INCOMING_CALL");
        PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA);
        manager.open(me, pi, null);

        // This listener must be added AFTER manager.open is called,
        // Otherwise the methods aren't guaranteed to fire.

        manager.setRegistrationListener(me.getUriString(), new SipRegistrationListener() {
                public void onRegistering(String localProfileUri) {
                    updateStatus("Registering with SIP Server...");
                }

                public void onRegistrationDone(String localProfileUri, long expiryTime) {
                    updateStatus("Ready");
                }

                public void onRegistrationFailed(String localProfileUri, int errorCode,
                        String errorMessage) {
                    updateStatus("Registration failed.  Please check settings.");
                }
            });
    } catch (ParseException pe) {
        updateStatus("Connection Error.");
    } catch (SipException se) {
        updateStatus("Connection error.");
    }
}
4

0 回答 0