public void setAccountTransport(int n, String transport) {
    LinphoneProxyConfig proxyConfig = getProxyConfig(n);

    if (proxyConfig != null && transport != null) {
      LinphoneAddress proxyAddr;
      try {
        proxyAddr = LinphoneCoreFactory.instance().createLinphoneAddress(proxyConfig.getProxy());
        int port = 0;
        if (transport.equals(getString(R.string.pref_transport_udp_key))) {
          proxyAddr.setTransport(TransportType.LinphoneTransportUdp);
        } else if (transport.equals(getString(R.string.pref_transport_tcp_key))) {
          proxyAddr.setTransport(TransportType.LinphoneTransportTcp);
        } else if (transport.equals(getString(R.string.pref_transport_tls_key))) {
          proxyAddr.setTransport(TransportType.LinphoneTransportTls);
          port = 5223;
        }

        /* 3G mobile firewall might block random TLS port, so we force use of 5223.
         * However we must NOT use this port when changing to TCP/UDP because otherwise
         * REGISTER (and everything actually) will fail...
         * */
        if ("sip.linphone.org".equals(proxyConfig.getDomain())) {
          proxyAddr.setPort(port);
        }

        LinphoneProxyConfig prxCfg = getProxyConfig(n);
        prxCfg.edit();
        prxCfg.setProxy(proxyAddr.asStringUriOnly());
        prxCfg.done();

        if (isAccountOutboundProxySet(n)) {
          setAccountOutboundProxyEnabled(n, true);
        }
      } catch (LinphoneCoreException e) {
        e.printStackTrace();
      }
    }
  }
  private void displayContact(LayoutInflater inflater, View view) {
    AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);
    if (contact.getPhotoUri() != null) {
      InputStream input =
          Compatibility.getContactPictureInputStream(
              LinphoneActivity.instance().getContentResolver(), contact.getID());
      contactPicture.setImageBitmap(BitmapFactory.decodeStream(input));
    } else {
      contactPicture.setImageResource(R.drawable.unknown_small);
    }

    TextView contactName = (TextView) view.findViewById(R.id.contactName);
    contactName.setText(contact.getName());

    TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
    controls.removeAllViews();
    for (String numberOrAddress : contact.getNumerosOrAddresses()) {
      View v = inflater.inflate(R.layout.contact_control_row, null);

      String displayednumberOrAddress = numberOrAddress;
      if (numberOrAddress.startsWith("sip:")) {
        displayednumberOrAddress = displayednumberOrAddress.replace("sip:", "");
      }

      TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
      tv.setText(displayednumberOrAddress);
      tv.setSelected(true);

      if (!displayChatAddressOnly) {
        v.findViewById(R.id.dial).setOnClickListener(dialListener);
        v.findViewById(R.id.dial).setTag(displayednumberOrAddress);
      } else {
        v.findViewById(R.id.dial).setVisibility(View.GONE);
      }

      v.findViewById(R.id.start_chat).setOnClickListener(chatListener);
      LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
      if (lpc != null) {
        if (!displayednumberOrAddress.startsWith("sip:")) {
          numberOrAddress = "sip:" + displayednumberOrAddress;
        }

        String tag = numberOrAddress;
        if (!numberOrAddress.contains("@")) {
          tag = numberOrAddress + "@" + lpc.getDomain();
        }
        v.findViewById(R.id.start_chat).setTag(tag);
      } else {
        v.findViewById(R.id.start_chat).setTag(numberOrAddress);
      }

      final String finalNumberOrAddress = numberOrAddress;
      ImageView friend = (ImageView) v.findViewById(R.id.addFriend);
      if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) {
        friend.setVisibility(View.VISIBLE);

        boolean isAlreadyAFriend =
            LinphoneManager.getLc().findFriendByAddress(finalNumberOrAddress) != null;
        if (!isAlreadyAFriend) {
          friend.setImageResource(R.drawable.friend_add);
          friend.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) {
                    displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
                  }
                }
              });
        } else {
          friend.setImageResource(R.drawable.friend_remove);
          friend.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) {
                    displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
                  }
                }
              });
        }
      }

      if (getResources().getBoolean(R.bool.disable_chat)) {
        v.findViewById(R.id.start_chat).setVisibility(View.GONE);
      }

      controls.addView(v);
    }
  }