UnifiedContactPicker
UnifiedContactPicker copied to clipboard
I dont want emails . I want to extract phone numbers only
Hey The library is awesome and build very well. I want to implement phone numbers not email . There should be an optional argument for both contact phone number and contact email.
Also it would be nice if I could get only contact with email addresses. Nice library btw :-)
You should add:
contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_SELECTION, CP_SELECTION); contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_SELECTION_ARGS, CP_SELECTION_ARGS);
and
public static final String CP_SELECTION = "(" + ContactsContract.Data.MIMETYPE + "=?)"; public static final String [] CP_SELECTION_ARGS = new String[] { ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE };
Here is the solution. For emails only please refer the closed issue #1
public void launchContactPicker(View view) {
Intent contactPicker = new Intent(this, ContactPickerActivity.class);
//phone numbers only
String customSelection = "(" + ContactsContract.Data.MIMETYPE + "=? )";
String [] customArgs = new String [] {ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE};
contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_SELECTION,customSelection);
contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_SELECTION_ARGS, customArgs);
contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_HAS_CUSTOM_SELECTION_ARGS, true);
startActivityForResult(contactPicker, CONTACT_PICKER_REQUEST);}