Android以编程方式创建SIP帐户

时间:2014-01-08 16:40:02

标签: android settings add sip account

在我的应用程序中,我希望有一个Activity,允许用户在字段中添加他的SIP帐户参数。 我不希望他们去设置 - >来电 - >互联网电话设置 - >添加帐户 - >添加

我使用以下代码创建了包含活动的帐户:

SipManager mSipManager = null;

    if(mSipManager == null) {
        mSipManager = SipManager.newInstance(this);
    }

    android.provider.Settings.System.putInt(context.getContentResolver(), android.provider.Settings.System.s , 0)
    SipProfile mSipProfile = null;
    SipManager manager = SipManager.newInstance(getBaseContext());

    SipProfile.Builder builder;
    try {
        builder = new SipProfile.Builder("XXXXX", "sip.linphone.org");
        builder.setPassword("XXX");
        mSipProfile = builder.build();
        manager.open(mSipProfile);
        //manager.register(mSipProfile, 30, MyActivity.this);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

但帐户绑定到应用程序,当我删除应用程序时,它会删除该帐户。我希望它独立于应用程序。

1 个答案:

答案 0 :(得分:2)

为什么不启动系统sip设置活动,他们不必通过系统导航,但可以将帐户添加到系统。

if (SipManager.isVoipSupported(this) && SipManager.isApiSupported(this)){
   // SIP is supported, let's go!
   Intent intent = new Intent();
   intent.setAction("android.intent.action.MAIN");
   intent.setComponent(ComponentName.unflattenFromString("com.android.phone/.sip.SipSettings"));
   startActivity(intent); }
相关问题