contactscontract

Android: Accessing and querying properly using Raw Contact Id

半世苍凉 提交于 2019-12-11 22:54:19
问题 So my app is attempting to integrate a sync adapter to the android native contact manager. This is all running smoothly except once a contact is synced, I am unable to update it. Details on this particular problem can be found here: Android: Content resolver query returning 0 rows when it ought not to But I can sum it up simply by just saying my content resolver query is returning 0 values because I am querying the wrong URI, I believe. When I write the raw contact id to the phone, I do it

Optimise thousands of SQLite queries android

北战南征 提交于 2019-12-11 21:28:16
问题 I have this task where I need to query all details about every contact and back it up. The first 770 contacts take up 5-6 seconds to load while after 770 contacts, each contact takes more than a second to query all data. I understand that this is a complex query but that is just too slow. Is there any way to optimize this? Code // This contacts array typically contains more than a thousand items in it, even more contacts.forEach { val lookupKey = it.lookupKey queryContacts(lookupKey) } fun

Android MultiAutoCompleteTextView to retrieve multiple contacts

我们两清 提交于 2019-12-11 20:37:17
问题 I am trying to modify a code that I have seen on stackoverflow for an AutoCompleteTextView so that i would return mutliple contacts for a MultiAutoCompleteTextView. However, when I load this onto my Android phone I can no longer see any suggestions to select from. I have feeling that the problem lies in the ArrayAdapter initialization but I cannot figure out what is wrong with it. Thanks in advance for any help. I have the following code for my multiautocompletetextview:

Update existing contact with image in Android

自闭症网瘾萝莉.ら 提交于 2019-12-11 10:54:10
问题 I am able to update image in contact from my app and its visible in contacts but as soon as google sync occurs it deletes the image from contact. My code: ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) .withValue(ContactsContract.Data.RAW_CONTACT_ID, lRawContactId) .withValue(ContactsContract.Data.IS_PRIMARY, 1) .withValue(ContactsContract.Data.IS_SUPER_PRIMARY, 1) .withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM

contentResolver.query(ContactsContract.Contacts.CONTENT_URI…) return 0 count Cursor if called after Intent.ACTION_INSERT

南笙酒味 提交于 2019-12-11 10:50:37
问题 I'm getting a weird behavior when testing my app on Huawei P8 . Everything works nice on emulators (android version 4, 5, 6, 7) and on ASUS (android 6) and Samsung Galaxy S2 (Android 4.2). The following steps work both on physical device and emulators. After calling contentResolver.query() I get a Cursor with all the contacts of my device. I open my app I call contentResolver.query(ContactsContract.Contacts.CONTENT_URI...); The following steps work everywhere except on my Huawei P8 ; with my

Getting null value while retrieving the CONTACT NAME from CONTACT EMAIL

萝らか妹 提交于 2019-12-11 10:47:09
问题 I want to retrieve the contact name from the contact email, so what I have done is as follows from https://stackoverflow.com/a/18064869/5738881. public static String readContacts(Context context, String email) { ContentResolver cr = context.getContentResolver(); Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(email)); Cursor cursor = cr.query(uri, new String[]{ContactsContract.PhoneLookup.DISPLAY_NAME}, null, null, null); if (cursor == null) { return

When I select contact name and address from contact list address data not retrieved

给你一囗甜甜゛ 提交于 2019-12-11 07:55:29
问题 I need to get contact name and relevant address from contact list in android. I get the contact name and their phone number, but unfortunately unable to get the address details. When I select the contact address, it will return null every time. I searched the google as well as stackoverflow. But unable to find a solution. When I searched I found that, address details are in another separate table, but I searched that table with id, but didn't return the data from the address table. So please

Adding new contact with photo via ContactsContract and ContentProvider

好久不见. 提交于 2019-12-11 03:08:12
问题 I've been trying all day to add contact with photo to Android Contacts. Finally I'm adding picture to contact, but I can't add any name or phone number. Contact is displaying as "(Unknown)", with proper photo. My code: private void addContact2() { final String displayName = "XYZA"; final String mobileNumber = "666666"; final byte[] photoByteArray; // initalized elsewhere ArrayList<ContentProviderOperation> ops = new ArrayList<>(); ops.add(ContentProviderOperation.newInsert(ContactsContract

Get contact's mobile, work and home number in a string

独自空忆成欢 提交于 2019-12-11 01:13:50
问题 I want to get the contact's(Saved in phonebook) mobile number, work number and home number. I want to set these numbers in my 3 edittext views. How to do this? Here is my code Cursor phones = getActivity().getContentResolver().query( Phone.CONTENT_URI, null, Phone.CONTACT_ID + " = " + phoneId, null, null ); while (phones.moveToNext()) { number = phones.getString(phones.getColumnIndex(Phone.NUMBER)); int type = phones.getInt(phones.getColumnIndex(Phone.TYPE)); if (type == Phone.TYPE_HOME) {

Merging raw contacts

三世轮回 提交于 2019-12-10 23:42:58
问题 I have an account and a sync adapter which add new raw contacts with corresponding private data entries. the contacts I'm creating are phone number based, meaning I'm creating a new entry per existing phone number. How do I merge my raw contact with the existing raw contact that was linked to the existing phone number? I've tried creating a new phone number entry in the data table, and link it to the raw contacts I'm adding. it works, but It's creating a duplication phone number. I've also