Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - cant get phone number of some contacts
    primarykey
    data
    text
    <p>I'm having a problem with extracting phone numbers of some people in my contact list.</p> <p>First I show all the contacts in a listview:</p> <pre><code>String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER }; mCursor = mContext.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=?", new String[] {mContactId}, null); </code></pre> <p>When clicking on an item, this is how I fetch the contact_id:</p> <pre><code>@Override public void onListItemClick(ListView l, View v, int position, long id) { Cursor currentCursor = mContactsAdapter.getCursor(); if (currentCursor != null) { notifyOnContactSelectedListeners(String.valueOf(id)); } } </code></pre> <p>Then I create a new fragment, and while loading it I query for the contact's phone &amp; display name:</p> <pre><code>if (cursor != null &amp;&amp; cursor.getCount() &gt; 0) { cursor.moveToFirst(); String firstName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)); String number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); } </code></pre> <p>So for some people that has a phone, I get the phone number this way and that's ok. But for some people I can't get the phone number this way - but they do have phone number in the default's phone contacts book.</p> <p>What went wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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