Android Create Sip Account Programmatically

Misha Akopov picture Misha Akopov · Jan 8, 2014 · Viewed 10.7k times · Source

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.

Answer

Totoo picture Totoo · May 9, 2015

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