contactscontract

Getting Number from Contacts Picker

可紊 提交于 2019-11-27 19:33:36
I am trying to get a contacts name and phone number after a user has picked a contact from the Contact Picker. I am attempting to make my application work for SDK v3 and up so I created an abstract class that would call only the API that I needed. I already have the abstract class working (it chooses the right API) and I also have the API for SDK v3,4 working. I am having problems getting the newer API that uses ContactsContract to work. I can get a contacts name, but the number it retrieves is always the number for the contact ID BEFORE it! Example: I have 2 contacts "John Doe" and "Jane Doe"

How do I make my Android ContentObserver for ContactsContract detect a added, updated or deleted contact?

◇◆丶佛笑我妖孽 提交于 2019-11-27 19:01:23
I am able to get a generic notification "that there was a change to the contacts DB", but I want to know the specific record that was inserted, updated, or deleted. Following is the code that gets registered and gets the onChange notification. Unfortunately, it is not specific which makes my processing exhaustive and inefficient. Here is the code stub: if ((mNativeContactsObserver == null) && (mHandler == null)) { mHandler = new Handler(this.getMainLooper()) { }; mNativeContactsObserver = new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { super.onChange

What is the default Account Type / Name for contacts on Android Contact Application?

落花浮王杯 提交于 2019-11-27 14:24:06
I would like to read contacts from ContactsContract API which belongs only to Phone / SIM and would like to avoid contacts synced from other apps like facebook and gmail. I tested my code on simulator and it works fine but on real devices it doesn't returns any result. ContentResolver cr = AndroidContext.getContext() .getContentResolver(); Cursor nativeContacts = cr.query(RawContacts.CONTENT_URI, new String[] { RawContacts._ID, RawContacts.VERSION, RawContacts.CONTACT_ID }, RawContacts.DELETED + "<> 1 AND " + RawContacts.CONTACT_ID + " IS NOT NULL AND " + RawContacts.ACCOUNT_NAME + " IS NULL

New contacts created using ContactsContract do not appear in Contacts app

随声附和 提交于 2019-11-27 14:15:03
I'm using the following piece of codes to create a new contact. It follow closely the ContactManager example provided by Android. The problem is, the created contacts do not appear in the Contacts app that shipped with Android. Nevertheless, when I load all the contacts from the phonebook, I can see the newly created contacts. private void insertPBEntry() throws RemoteException, OperationApplicationException { ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI) .withValue

why won't contacts aggregate?

喜夏-厌秋 提交于 2019-11-27 08:45:55
问题 My app allows editing contacts. In this scenario, I chose a contact which existed in only one account and changed it to associate it with three accounts. However, I ended up with two contacts, not one, as shown in the ContactsContract dump below. Why didn't the provider aggregate them? agg 1821, display "A Z1", key 770i236434918d3893ea.2709i79dde86f8c1565d3.2709i506dc01a0d43d677.2709i4707c358f8fb503 raw 1821, acct type com.google, acct name a@gmail.com data 10338, display "A Z1" data 10343,

Cannot retrieve email from Contacts

好久不见. 提交于 2019-11-27 08:34:25
问题 I want to retrieve email,phone number and contact names from my phone-book and display them in list-view. The name and numbers are coming perfectly but the emails are not retrieving. Here is the relevant code: public void getAllContacts(ContentResolver cr) { String email=""; Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, Phone.DISPLAY_NAME + " ASC"); //email = new String[phones.getCount()]; while (phones.moveToNext()) { String id = phones

Getting Number from Contacts Picker

时光总嘲笑我的痴心妄想 提交于 2019-11-27 04:22:45
问题 I am trying to get a contacts name and phone number after a user has picked a contact from the Contact Picker. I am attempting to make my application work for SDK v3 and up so I created an abstract class that would call only the API that I needed. I already have the abstract class working (it chooses the right API) and I also have the API for SDK v3,4 working. I am having problems getting the newer API that uses ContactsContract to work. I can get a contacts name, but the number it retrieves

Modifying contact information

青春壹個敷衍的年華 提交于 2019-11-27 01:08:24
I'm trying to insert and update a piece of information on an existing contact so I've created a sample application in order to develop the functionality. All I want my sample app to do is to insert (or if present) update an email address on a contact. I'm selecting a contact through the system Intent like so: startActivityForResult(new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI), PICK_CONTACT_REQUEST); The URI which is returned is that of the Contact ( RawContact ?) which was selected and comes in this form: content://com.android.contacts/contacts/lookup/0r2-2A90214945/2 . I can pull back

MultiAutoCompleteTextView with contacts phone numbers

天大地大妈咪最大 提交于 2019-11-26 23:40:37
问题 I need to create a MultiAutoCompleteTextView with the phone numbers of the contacts on a user's device. What I need is similar to gmail; except with gmail email addresses are used. For the contacts, I have the following needs: each phone number must be an entry. So if John has 3 numbers (home, cell, work), they show as 3 entries each entry is searchable by phone number or by first/last name of person To create my adapter, I try to modify the one provided by Google but when I download the

Android contacts Display Name and Phone Number(s) in single database query?

…衆ロ難τιáo~ 提交于 2019-11-26 19:31:19
I'm trying to obtain a list of contacts from the native database with their Display Name and Phone Number (any or all). There are many methods for obtaining this information with several queries to the phone's database, but this introduces considerable overhead. Here is the query I've been working on, but it results in Uri uri = ContactsContract.Contacts.CONTENT_URI; String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER}; String selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '1'";