Android Create Sip Account Programmatically

浪子不回头ぞ 提交于 2019-12-03 07:28:30

问题


In my application I want to have one Activity that enables user to add his SIP account parameters in fields. I don't want them to go Settings->Call->Internet Call Settings->Add Accounts->Add

I have created account with activity with the following code:

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();
    }

But the account is bound to the application, and when I delete app, it deletes the account. I want it to be independent of the application.


回答1:


Why not start the system sip settings activity, and they don't have to navigate trough the system, but can add the account to system.

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); }


来源:https://stackoverflow.com/questions/21001463/android-create-sip-account-programmatically

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