List of usage examples for android.accounts AccountManager get
public static AccountManager get(Context context)
From source file:Main.java
/** * Check if exist auth token for specified account * @param context context//from www . j a va2 s . c o m * @param account account to check * @param authTokenType auth token type * @return <code>true</code> if authToken for this account exist */ public static boolean isAccountEnabled(Context context, Account account, String authTokenType) { if (account == null) return false; final AccountManager accountManager = AccountManager.get(context); String authToken = accountManager.peekAuthToken(account, authTokenType); if (TextUtils.isEmpty(authToken)) { return false; } else { return true; } }
From source file:Main.java
public static Account getActiveAccount(final Context context, final String accountType) { Account[] accounts = AccountManager.get(context).getAccountsByType(accountType); return getActiveAccount(accounts, getActiveAccountName(context)); }
From source file:Main.java
/** * @param context//from w ww . j a v a2s. com * this method is used for retrieving email accounts of device * @return */ public static String[] getAccount(Context context) { final AccountManager accountManager = AccountManager.get(context); final Account[] accounts = accountManager.getAccounts(); final Vector<String> accountVector = new Vector<String>(); for (int i = 0; i < accounts.length; i++) { if (!accountVector.contains(accounts[i].name) && isValidEmail(accounts[i].name)) { accountVector.addElement(accounts[i].name); } } final String accountArray[] = new String[accountVector.size()]; return accountVector.toArray(accountArray); }
From source file:Main.java
public static String getUserToken(Context context, Account account) { AccountManager manager = AccountManager.get(context); return manager.getUserData(account, AccountManager.KEY_AUTHTOKEN); }
From source file:Main.java
public static String getUrl(Context context, Account account) { AccountManager manager = AccountManager.get(context); return manager.getUserData(account, USER_URL); }
From source file:Main.java
public static String getUserAvatar(Context context, Account account) { AccountManager manager = AccountManager.get(context); return manager.getUserData(account, USER_PIC); }
From source file:Main.java
public static String getUserMail(Context context, Account account) { AccountManager manager = AccountManager.get(context); return manager.getUserData(account, USER_MAIL); }
From source file:Main.java
public static String getUserName(Context context, Account account) { AccountManager manager = AccountManager.get(context); return manager.getUserData(account, USER_NAME); }
From source file:Main.java
/** * Recreate account//ww w . ja v a2s . c o m * @param account account * @param authTokenType authTokenType * @param requiredFeatures requiredFeatures, could be <code>null</code> * @param options options, could be <code>null</code> * @param activity activity (cannot be <code>null</code>) */ public static void reCreateAccount(Account account, String accountType, String authTokenType, String[] requiredFeatures, Bundle options, Activity activity) { if (activity == null) { throw new IllegalArgumentException("activity cannot be null"); } final AccountManager accountManager = AccountManager.get(activity.getApplicationContext()); if (isAccountExist(activity, account)) { accountManager.removeAccount(account, null, null); } accountManager.addAccount(accountType, authTokenType, requiredFeatures, options, activity, null, null); }
From source file:Main.java
/** * Retrieves all of the Google accounts on the device * @param context/* ww w . j a v a 2 s. c o m*/ * @return */ public static Account[] getGoogleAccounts(Context context) { return AccountManager.get(context).getAccountsByType(GOOGLE_ACCOUNT_TYPE); }