private void requestMetadataSyncForAccount(String accountName) {
for (Account account : getFocusGoogleAccounts()) {
if (!TextUtils.isEmpty(accountName) && accountName.equals(account.name)) {
final Bundle b = new Bundle();
b.putBoolean(SHOULD_CLEAR_METADATA_BEFORE_SYNCING, true);
b.putBoolean(ONLY_CLEAR_DONOT_SYNC, false);
b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
ContentResolver.requestSync(account, CONTACT_METADATA_AUTHORITY, b);
ContentResolver.setSyncAutomatically(account, CONTACT_METADATA_AUTHORITY, true);
} else if (ContentResolver.getSyncAutomatically(account, CONTACT_METADATA_AUTHORITY)) {
ContentResolver.setSyncAutomatically(account, CONTACT_METADATA_AUTHORITY, false);
if (TextUtils.isEmpty(accountName)) {
final Bundle b = new Bundle();
b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
b.putBoolean(SHOULD_CLEAR_METADATA_BEFORE_SYNCING, true);
b.putBoolean(ONLY_CLEAR_DONOT_SYNC, true);
ContentResolver.requestSync(account, CONTACT_METADATA_AUTHORITY, b);
}
}
}
}