Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>try this as this works for me:</p> <pre><code>Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); startActivityForResult(intent, AppConstants.PICK_CONTACT); </code></pre> <p>then in onActivityResult do the following:</p> <pre><code>Cursor cursor = null; String phoneNumber = "", primaryMobile = ""; List&lt;String&gt; allNumbers = new ArrayList&lt;String&gt;(); int contactIdColumnId = 0, phoneColumnID = 0, nameColumnID = 0; try { Uri result = data.getData(); Utils.printLog(TAG, result.toString()); String id = result.getLastPathSegment(); cursor = getContentResolver().query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + "=?", new String[] { id }, null); contactIdColumnId = cursor.getColumnIndex(ContactsContract.Data.RAW_CONTACT_ID); phoneColumnID = cursor.getColumnIndex(Phone.DATA); nameColumnID = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); if (cursor.moveToFirst()) { while (cursor.isAfterLast() == false) { idContactBook = cursor.getString(contactIdColumnId); displayName = cursor.getString(nameColumnID); phoneNumber = cursor.getString(phoneColumnID); if (phoneNumber.length() == 0) continue; int type = cursor.getInt(cursor.getColumnIndex(Phone.TYPE)); if (type == Phone.TYPE_MOBILE &amp;&amp; primaryMobile.equals("")) primaryMobile = phoneNumber; allNumbers.add(phoneNumber); cursor.moveToNext(); } } else { // no results actions } } catch (Exception e) { // error actions } finally { if (cursor != null) { cursor.close(); } } </code></pre>
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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