Search in sources :

Example 51 with AccountManager

use of android.accounts.AccountManager in project aware-client by denzilferreira.

the class Aware method getAWAREAccount.

/**
 * Return AWARE's account
 *
 * @param context
 * @return
 */
public static Account getAWAREAccount(Context context) {
    AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);
    Account[] accounts = accountManager.getAccountsByType(Aware_Accounts.Aware_Account.AWARE_ACCOUNT_TYPE);
    if (accounts.length > 0) {
        aware_account = accounts[0];
        return aware_account;
    }
    if (aware_account == null) {
        aware_account = new Account(Aware_Accounts.Aware_Account.AWARE_ACCOUNT, Aware_Accounts.Aware_Account.AWARE_ACCOUNT_TYPE);
        try {
            accountManager.addAccountExplicitly(aware_account, null, null);
        } catch (SecurityException e) {
            e.printStackTrace();
        }
    }
    return aware_account;
}
Also used : Account(android.accounts.Account) AccountManager(android.accounts.AccountManager)

Example 52 with AccountManager

use of android.accounts.AccountManager in project 360-Engine-for-Android by 360.

the class NativeContactsApi2 method getAccounts.

/**
 * @see NativeContactsApi#getAccounts()
 */
@Override
public Account[] getAccounts() {
    AccountManager accountManager = AccountManager.get(mContext);
    final android.accounts.Account[] accounts2xApi = accountManager.getAccounts();
    Account[] accounts = null;
    if (accounts2xApi.length > 0) {
        accounts = new Account[accounts2xApi.length];
        for (int i = 0; i < accounts2xApi.length; i++) {
            accounts[i] = new Account(accounts2xApi[i].name, accounts2xApi[i].type);
        }
    }
    return accounts;
}
Also used : AccountManager(android.accounts.AccountManager)

Example 53 with AccountManager

use of android.accounts.AccountManager in project 360-Engine-for-Android by 360.

the class NativeContactsApi2 method removePeopleAccount.

/**
 * @see NativeContactsApi#removePeopleAccount()
 */
@Override
public void removePeopleAccount() {
    AccountManager accountMan = AccountManager.get(mContext);
    android.accounts.Account[] accounts = accountMan.getAccountsByType(PEOPLE_ACCOUNT_TYPE_STRING);
    if (accounts != null && accounts.length > 0) {
        accountMan.removeAccount(accounts[0], null, null);
    }
}
Also used : AccountManager(android.accounts.AccountManager)

Example 54 with AccountManager

use of android.accounts.AccountManager in project 360-Engine-for-Android by 360.

the class NativeContactsApi2 method addPeopleAccount.

/**
 * @see NativeContactsApi#addPeopleAccount(String)
 */
@Override
public boolean addPeopleAccount(String username) {
    boolean isAdded = false;
    try {
        android.accounts.Account account = new android.accounts.Account(username, PEOPLE_ACCOUNT_TYPE_STRING);
        AccountManager accountMan = AccountManager.get(mContext);
        isAdded = accountMan.addAccountExplicitly(account, null, null);
        if (isAdded) {
            if (VersionUtils.isHtcSenseDevice(mContext)) {
                createSettingsEntryForAccount(username);
                requestSyncAdapterInitialization(account);
            }
            // Need to do our Sync Adapter initialization logic here
            SyncAdapter.initialize(account, ContactsContract.AUTHORITY);
        }
    } catch (Exception ex) {
        LogUtils.logE("People Account creation failed because of exception:\n", ex);
    }
    return isAdded;
}
Also used : AccountManager(android.accounts.AccountManager) RemoteException(android.os.RemoteException) OperationApplicationException(android.content.OperationApplicationException)

Example 55 with AccountManager

use of android.accounts.AccountManager in project android_frameworks_base by crdroidandroid.

the class SuggestionParser method satisfiesRequiredAccount.

public boolean satisfiesRequiredAccount(Tile suggestion) {
    String requiredAccountType = suggestion.metaData.getString(META_DATA_REQUIRE_ACCOUNT);
    if (requiredAccountType == null) {
        return true;
    }
    AccountManager accountManager = AccountManager.get(mContext);
    Account[] accounts = accountManager.getAccountsByType(requiredAccountType);
    return accounts.length > 0;
}
Also used : Account(android.accounts.Account) AccountManager(android.accounts.AccountManager)

Aggregations

AccountManager (android.accounts.AccountManager)105 Account (android.accounts.Account)76 Bundle (android.os.Bundle)14 IOException (java.io.IOException)11 Intent (android.content.Intent)10 OperationCanceledException (android.accounts.OperationCanceledException)7 AuthenticatorException (android.accounts.AuthenticatorException)5 View (android.view.View)5 TextView (android.widget.TextView)5 HashSet (java.util.HashSet)5 SharedPreferences (android.content.SharedPreferences)4 AccountManagerCallback (android.accounts.AccountManagerCallback)3 Paint (android.graphics.Paint)3 JSONException (org.json.JSONException)3 AccountsException (android.accounts.AccountsException)2 TargetApi (android.annotation.TargetApi)2 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 OperationApplicationException (android.content.OperationApplicationException)2