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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations