Example usage for android.accounts AccountManager get

List of usage examples for android.accounts AccountManager get

Introduction

In this page you can find the example usage for android.accounts AccountManager get.

Prototype

public static AccountManager get(Context context) 

Source Link

Document

Gets an AccountManager instance associated with a Context.

Usage

From source file:Main.java

public static boolean addAccountExplicitly(Account account, String password, Context context) {
    return AccountManager.get(context).addAccountExplicitly(account, password, null);
}

From source file:Main.java

public static void removeAccount(Account account, Context context) {
    AccountManager.get(context).removeAccount(account, null, null);
}

From source file:Main.java

public static Account[] getAccounts(Context context, String type) {
    return AccountManager.get(context).getAccountsByType(type);
}

From source file:Main.java

public static String getPassword(Account account, Context context) {
    return AccountManager.get(context).getPassword(account);
}

From source file:Main.java

public static void setPassword(Account account, String password, Context context) {
    AccountManager.get(context).setPassword(account, password);
}

From source file:Main.java

public static Account[] getAccounts(Context context) {
    AccountManager accountManager = AccountManager.get(context);
    Account[] accounts = null;/*from  w ww.  j  ava2  s .  c  om*/
    try {
        accounts = accountManager.getAccounts();
    } catch (Exception e) {
    }
    return accounts;
}

From source file:Main.java

public static void invalidateAuthToken(Context context, String s) {
    AccountManager.get(context).invalidateAuthToken(ACCOUNT_TYPE, s);
}

From source file:Main.java

public static String getPassword(Context context, Account account) {
    AccountManager accountManager = AccountManager.get(context);
    return accountManager.getPassword(account);
}

From source file:Main.java

static public String getEmail(Context context) {
    AccountManager accountManager = AccountManager.get(context);
    Account account = getAccount(accountManager);

    if (account == null) {
        return null;
    } else {//  w w w  .  jav a  2  s.  com
        return account.name;
    }
}

From source file:Main.java

public static Account[] getSpecificAccounts(Context context, String accountType) {
    Account accounts[] = AccountManager.get(context).getAccountsByType(accountType);
    if (accounts.length != 0) {
        return accounts;
    } else {//  w  ww .ja v a  2  s. c o  m
        return null;
    }
}