List of usage examples for android.accounts AccountManager notifyAccountAuthenticated
public boolean notifyAccountAuthenticated(Account account)
From source file:saschpe.birthdays.helper.AccountHelper.java
public static Bundle addAccount(Context context) { Log.d(TAG, "AccountHelper.addAccount: Adding account..."); final Account account = new Account(context.getString(R.string.app_name), context.getString(R.string.account_type)); AccountManager manager = AccountManager.get(context); if (manager.addAccountExplicitly(account, null, null)) { // Enable automatic sync once per day ContentResolver.setSyncAutomatically(account, context.getString(R.string.content_authority), true); ContentResolver.setIsSyncable(account, context.getString(R.string.content_authority), 1); // Add periodic sync interval based on user preference final long freq = PreferencesHelper.getPeriodicSyncFrequency(context); ContentResolver.addPeriodicSync(account, context.getString(R.string.content_authority), new Bundle(), freq);/* w ww. ja v a2 s .c o m*/ Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type); Log.i(TAG, "Account added: " + account.name); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { manager.notifyAccountAuthenticated(account); } return result; } else { Log.e(TAG, "Adding account explicitly failed!"); return null; } }