Contact Picker Filtering
I use the contact picker in this way: Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); this.startActivityForResult(intent, PICK_CONTACT_REQUEST); My q
Solution 1:
I would suggest to use your custom view for the contacts- it is not rather difficult and you can customize it however you want. I personally implemented that way the functionality you need.
See here:
StringPHONE_CONTACTS_ORDER_CLAUSE= ContactsContract.Contacts.DISPLAY_NAME
+ " ASC";
List<PhoneContact> contacts = newArrayList<PhoneContact>(); // I have defined the bean PhoneContact
String[] projection = { ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME }; //Choose the columns you needCursorcursor=this.getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, projection, null/* the place for your where clause*/, null/* the place for your where args*/,
PHONE_CONTACTS_ORDER_CLAUSE);
startManagingCursor(cursor);
intcontactIdIdx= cursor.getColumnIndex(ContactsContract.Contacts._ID);
intdisplayNameIdx= cursor
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
while (cursor.moveToNext()) {
PhoneContactcontact=newPhoneContact(); // This is a class i defined, use the data the way you like.
contact.setContactId(cursor.getString(contactIdIdx));
contact.setDisplayName(cursor.getString(displayNameIdx));
contacts.add(contact);
}
EDIT Sorry got distracted when writing the comment: the Contact id is actually the glue between the different content providers of the Contact related data. These are a few more providers you can use to see whether there are any associated phones or emails with the contact:
ContactsContract.CommonDataKinds.Phone.CONTENT_URI
ContactsContract.CommonDataKinds.Email.CONTENT_URI
Post a Comment for "Contact Picker Filtering"