I am creating an autocomplete field that asks contacts by display name and email when someone is desired after filtering When a person clicks the contact, the contact is added to a list with his email, display his name and picture.
So far, I have managed to do everything I see. How do I run a query to get email, display name, ID, and photo ID?
Return mContent.query (email. CONTENT_URI, projection, filter, empty, empty); Where projection is:
projection = new string [] {ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_ID, E-mail. DATA}; This is the one which requires all the data and gives returns. But during debugging this issue, one thing I know is that if you run queries against contact, the contact ID is different. For example, contact for a specific display name. CONTENT_URI For example, the test run by me where I get all the contact after contacting. CONTENT_URI gave me contact with an image and 152 ID. Although the query against the email. CONTENT_URI gives me an ID of 452 (same display name and email address) for the same contact. So when I try to get the photo for content containing the ID 452 it shows that the picture is not present, but if I try to get the photo for 152 then it works perfectly.
What is the reason for this problem? How do I get the right user ID? Is there a relational query that I might run to get a contact ID, or maybe it's the right way to get it with the help of one.
Thank you.
Edit I got digging around this old code.
Therefore full query:
string [] projection = new string [] {ContactsContract.RawContacts._ID, contact contact.Communication .DISPLAY_NAME, contactCactrect.Communications. PHOTO_ID, Email Data, Contacts, Edit CommonDirects Photo. CONTACT_ID}; String Order = "When a Case" + Contact Contact. Contact .DISPLAY_NAME + "'not liked'% @% '' 1" + "2 seconds," + contact contact. Contact .DISPLAY_NAME + "COLLATE NOCASE"; String filter = e-mail Data + "not liked") by group ("+ email.account; then its
getContentResolver () query (email.contENT_URI, projection, Filter, blank, order);
, You must specify the contact photo URI, for example using this method:
Public URI Received Resource Photo Yuri (Long Contact ID) {Uri PhotoURI = Content Please contact CONTENT_URI, contactId; photoUri = Uri.withAppendedPath (photoUri, ContactsContract.Contacts.Photo.CONTENT_DIRECTORY); Return photoUri;} But for the contact ID you use To do this:
string id = contact contact .comdemdetakind.photocontactedidid; long contact id = long.secause long (id); Please note Instead of ContactsContract.Contacts._ID ContactsContract.CommonDataKinds.Photo.CONTACT_ID I hope that can help you.
Comments
Post a Comment