Code example for AccountManager

Methods: getUserData

0
   * @param b 
   *          The Bundle with all necessary informations for the server instance 
   */ 
  public ServerInstance(final AccountManager accManager, final Account account) {
    this.id = account.name;
    this.host = accManager.getUserData(account, "host");
    int p = 389;
    try { 
      p = Integer.parseInt(accManager.getUserData(account, "port"));
    } catch (Exception e) {
    } finally { 
      this.port = p;
    } 
    boolean ssl = false;
    try { 
      ssl = Boolean.parseBoolean(accManager.getUserData(account, "useSSL"));
    } catch (Exception e) {
    } finally { 
      this.useSSL = ssl;
    } 
    boolean tls = false;
    try { 
      tls = Boolean
          .parseBoolean(accManager.getUserData(account, "useStartTLS"));
    } catch (Exception e) {
    } finally { 
      this.useStartTLS = tls;
    } 
    this.bindDN = (accManager.getUserData(account, "bindDN") == null)
        || (accManager.getUserData(account, "bindDN").length() == 0) ? null
        : accManager.getUserData(account, "bindDN");
    this.bindPW = (accManager.getUserData(account, "bindPW") == null)
        || (accManager.getUserData(account, "bindPW").length() == 0) ? null
        : accManager.getUserData(account, "bindPW");
    this.baseDN = accManager.getUserData(account, "baseDN") == null ? ""
        : accManager.getUserData(account, "baseDN");
    this.filter = accManager.getUserData(account, "filter") == null ? ""
        : accManager.getUserData(account, "filter");
 
    String syncMan = accManager.getUserData(account, "manualSync");
    if (syncMan != null && syncMan.equalsIgnoreCase("true")) {
      this.syncAllContacts = false;
    } else { 
      this.syncAllContacts = true;
    }