ich bereits benutzerdefiniertes Konto mit Authenticator-Service & mein Konto erstellt haben bekommt erstellt successfully.This ist, wie ich Kontakt habe und fügte hinzu:Contact Sync-Adapter zeigt „Telefon nur, nicht synchronisierten Kontakt“
ContentResolver resolver = context.getContentResolver();
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation
.newInsert(addCallerIsSyncAdapterParameter(ContactsContract.RawContacts.CONTENT_URI, true))
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, context.getResources().getString(R.string.app_name))
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, context.getResources().getString(R.string.account_type))
.withValue(ContactsContract.RawContacts.AGGREGATION_MODE, ContactsContract.RawContacts.AGGREGATION_MODE_DEFAULT)
.build());
ops.add(ContentProviderOperation
.newInsert(addCallerIsSyncAdapterParameter(ContactsContract.Data.CONTENT_URI, true))
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, name)
.build());
ops.add(ContentProviderOperation
.newInsert(addCallerIsSyncAdapterParameter(ContactsContract.Data.CONTENT_URI, true))
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE, context.getResources().getString(R.string.mime_type))
.withValue(ContactsContract.Data.DATA1, context.getResources().getString(R.string.app_name))
.withValue(ContactsContract.Data.DATA2, context.getResources().getString(R.string.app_name))
.withValue(ContactsContract.Data.DATA3, context.getResources().getString(R.string.app_name))
.build());
ops.add(ContentProviderOperation.
newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.Contacts._ID, id)
.withValue(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE).build()
);
Log.e(TAG, "contact added: " + name + ", " + number);
try {
resolver.applyBatch(ContactsContract.AUTHORITY, ops);
} catch (Exception e) {
e.printStackTrace();
}
Telefon-Kontakte zeigt dies: "Nur Telefon, nicht synchronisierter Kontakt". Ich kann nicht herausfinden, was falsch ist.