/** * Lookup the numbers for a given contact. * * <p>Usually this is not needed because most methods already return the contacts with all known * contact numbers. Make sure to call {@link #contactsReadModuleInstalled()} first. * * @param contact */ public void lookupContactNumbersFor(Contact contact) { if (!contactsReadModuleInstalled()) return; String lookupKey = contact.getLookupKey(); // @formatter:off final String[] projection = new String[] {Phone.NUMBER, Phone.TYPE, Phone.LABEL, Phone.IS_SUPER_PRIMARY}; // @formatter:on final String selection = ContactsContract.PhoneLookup.LOOKUP_KEY + "=?" + AND + ContactsContract.Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"; final String[] selectionArgs = new String[] {lookupKey}; Cursor c = mContentResolver.query(MAXS_DATA_CONTENT_URI, projection, selection, selectionArgs, null); for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) { String number = c.getString(c.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER)); int type = c.getInt(c.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.TYPE)); String label = c.getString(c.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.LABEL)); boolean superPrimary = c.getInt(c.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY)) > 0 ? true : false; contact.addNumber(number, type, label, superPrimary); } c.close(); }