List of usage examples for android.accounts AccountManager getAccountsByType
@NonNull
public Account[] getAccountsByType(String type)
From source file:com.mobiperf.speedometer.AccountSelector.java
/** * Return the list of account names for users to select *//*from ww w. j ava2 s .c o m*/ public static String[] getAccountList(Context context) { AccountManager accountManager = AccountManager.get(context.getApplicationContext()); Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); String[] accountNames = null; if (accounts != null && accounts.length > 0) { accountNames = new String[accounts.length]; for (int i = 0; i < accounts.length; i++) { accountNames[i] = accounts[i].name; } } return accountNames; }
From source file:com.mobiperf.AccountSelector.java
/** * Return the list of account names for users to select *///from w w w .ja v a 2 s.c o m public static String[] getAccountList(Context context) { AccountManager accountManager = AccountManager.get(context.getApplicationContext()); Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); int numAccounts = accounts == null ? 1 : accounts.length + 1; String[] accountNames = new String[numAccounts]; for (int i = 0; i < accounts.length; i++) { accountNames[i] = accounts[i].name; } accountNames[numAccounts - 1] = context.getString(R.string.defaultUser); return accountNames; }
From source file:com.mobiperf_library.AccountSelector.java
/** * Return the list of account names for users to select *///from w w w . ja v a 2 s . c o m public static String[] getAccountList(Context context) { AccountManager accountManager = AccountManager.get(context.getApplicationContext()); Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); int numAccounts = accounts == null ? 1 : accounts.length + 1; String[] accountNames = new String[numAccounts]; for (int i = 0; i < accounts.length; i++) { accountNames[i] = accounts[i].name; } accountNames[numAccounts - 1] = Config.DEFAULT_USER; return accountNames; }
From source file:com.num.mobiperf.AccountSelector.java
/** * Return the list of account names for users to select *//*w w w .j a v a2s . co m*/ public static String[] getAccountList(Context context) { AccountManager accountManager = AccountManager.get(context.getApplicationContext()); Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); int numAccounts = accounts == null ? 1 : accounts.length + 1; String[] accountNames = new String[numAccounts]; for (int i = 0; i < accounts.length; i++) { accountNames[i] = accounts[i].name; } accountNames[numAccounts - 1] = "Anonymous"; return accountNames; }
From source file:com.mobilyzer.AccountSelector.java
/** * Return the list of account names for users to select *///www . j a v a 2 s . c o m public static String[] getAccountList(Context context) { if (!hasGetAccountsPermission(context)) { String[] accountNames = new String[1]; accountNames[0] = Config.DEFAULT_USER; return accountNames; } AccountManager accountManager = AccountManager.get(context.getApplicationContext()); Account[] accounts = accountManager.getAccountsByType(ACCOUNT_TYPE); int numAccounts = accounts == null ? 1 : accounts.length + 1; String[] accountNames = new String[numAccounts]; for (int i = 0; i < accounts.length; i++) { accountNames[i] = accounts[i].name; } accountNames[numAccounts - 1] = Config.DEFAULT_USER; return accountNames; }
From source file:com.cyanogenmod.account.util.CMAccountUtils.java
public static Account getCMAccountAccount(Context context) { final AccountManager am = AccountManager.get(context); Account[] accounts = am.getAccountsByType(CMAccount.ACCOUNT_TYPE_CMAccount); return accounts.length > 0 ? accounts[0] : null; }
From source file:com.phonemetra.account.util.AccountUtils.java
public static Account getAccountAccount(Context context) { final AccountManager am = AccountManager.get(context); Account[] accounts = am.getAccountsByType(Account.ACCOUNT_TYPE_Account); return accounts.length > 0 ? accounts[0] : null; }
From source file:com.ntsync.android.sync.shared.SyncUtils.java
public static void removePeriodicSync(String authority, Bundle extras, Context context) { AccountManager am = AccountManager.get(context); Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); for (Account ac : accounts) { ContentResolver.removePeriodicSync(ac, authority, extras); }//from w w w .j av a 2 s .com }
From source file:com.ntsync.android.sync.shared.SyncUtils.java
/** * // www . j a v a 2 s. com * @param authority * the provider to specify in the sync request * @param extras * extra parameters to go along with the sync request * @param frequency * in seconds * @param context */ public static void addPeriodicSync(String authority, Bundle extras, long frequency, Context context) { AccountManager am = AccountManager.get(context); Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); for (Account ac : accounts) { ContentResolver.addPeriodicSync(ac, authority, extras, frequency); } }
From source file:com.ntsync.android.sync.shared.SyncUtils.java
/** * Checks if some PaymentData is not yet verified * // w ww . j a v a 2s . c om * @param context * @return true if some PaymentData is open to verify */ public static boolean hasPaymentData(Context context) { boolean foundPaymentData = false; AccountManager acm = AccountManager.get(context); Account[] accounts = acm.getAccountsByType(Constants.ACCOUNT_TYPE); for (Account account : accounts) { PaymentData paymentData = SyncUtils.getPayment(account, acm); if (paymentData != null) { foundPaymentData = true; break; } } return foundPaymentData; }