Note that there are some explanatory texts on larger screens.

plurals
  1. POquerying contacts - SOMETIMES returns empty cursor
    text
    copied!<p>I'm trying to query contact's display name:</p> <pre><code>@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQ_CODE_PICK_CONTACT: if (resultCode == Activity.RESULT_OK) { Uri contactUri = data.getData(); ContentResolver cr = getActivity().getContentResolver(); Cursor c = cr.query(contactUri, null, null, null, null); if (c != null &amp;&amp; c.moveToFirst()) { //get the contact name } } break; } } </code></pre> <p>Now here is the problem:</p> <p>For some contacts the cursor returns empty, and I don't figure out why. I checked the value of <code>contactUri</code>, it looks like: content://com.android.contacts/data/3032</p> <p>The Uri looks the same for all types of contacts I tried - facebook, google, phone etc.</p> <p>For some contacts the cursor returns with a result, which is good and I can extract the name. But for others it's somehow empty even though the ContentUri is exactly the same, It was originated from Intent.getData().</p> <p>Here are some facts that may have something to do with this weird problem:</p> <ul> <li><p>All the contacts that has empty cursor are facebook contacts. the Uri looks like above.</p></li> <li><p>Not all the facebook contacts cause this: I have HTC One X, which on the phonebook I can "Link" between contacts if the OS finds a relation between them (say, if it detects the similar phone number for a gmail account and facebook acount, it suggests me to "link" between them). Only the facebook contacts who were NOT "Linked" returns empty.</p></li> </ul> <p>Right now im out of ideas. Did anyone encountered this before?</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload