Java 类android.provider.ContactsContract.Settings 实例源码

项目:PanBox    文件:AddressbookManagerAndroid.java   
public AddressbookManagerAndroid(Context context,
        ContentResolver contentResolver) {
    this.cr = contentResolver;
    // this.context = context;

    am = AccountManager.get(context);

    panboxAccount = new Account(accountName, accountType);
    am.addAccountExplicitly(panboxAccount, null, null);

    ContentProviderClient client = contentResolver
            .acquireContentProviderClient(ContactsContract.AUTHORITY_URI);
    ContentValues values = new ContentValues();
    values.put(ContactsContract.Groups.ACCOUNT_NAME, accountName);
    values.put(Groups.ACCOUNT_TYPE, accountType);
    values.put(Settings.UNGROUPED_VISIBLE, true);
    values.put(Settings.SHOULD_SYNC, false);
    try {
        client.insert(
                Settings.CONTENT_URI
                        .buildUpon()
                        .appendQueryParameter(
                                ContactsContract.CALLER_IS_SYNCADAPTER,
                                "true").build(), values);
    } catch (RemoteException e) {
        e.printStackTrace();
    }

}
项目:android-authenticator    文件:ContactManager.java   
/**
 * When we first add a sync adapter to the system, the contacts from that
 * sync adapter will be hidden unless they're merged/grouped with an existing
 * contact.  But typically we want to actually show those contacts, so we
 * need to mess with the Settings table to get them to show up.
 *
 * @param context the Authenticator Activity context
 * @param account the Account who's visibility we're changing
 * @param visible true if we want the contacts visible, false for hidden
 */
public static void setAccountContactsVisibility(Context context, Account account,
                                                boolean visible) {
    ContentValues values = new ContentValues();
    values.put(RawContacts.ACCOUNT_NAME, account.name);
    values.put(RawContacts.ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
    values.put(Settings.UNGROUPED_VISIBLE, visible ? 1 : 0);

    context.getContentResolver().insert(Settings.CONTENT_URI, values);
}
项目:ntsync-android    文件:ContactManager.java   
/**
 * When we first add a sync adapter to the system, the contacts from that
 * sync adapter will be hidden unless they're merged/grouped with an
 * existing contact. But typically we want to actually show those contacts,
 * so we need to mess with the Settings table to get them to show up.
 * 
 * @param context
 *            the Authenticator Activity context
 * @param account
 *            the Account who's visibility we're changing
 * @param visible
 *            true if we want the contacts visible, false for hidden
 */
public static void setAccountContactsVisibility(Context context,
        Account account, boolean visible) {
    ContentValues values = new ContentValues();
    values.put(RawContacts.ACCOUNT_NAME, account.name);
    values.put(RawContacts.ACCOUNT_TYPE, Constants.ACCOUNT_TYPE);
    values.put(Settings.UNGROUPED_VISIBLE, visible ? 1 : 0);

    context.getContentResolver().insert(Settings.CONTENT_URI, values);
}