I am trying to select contacts available from the phone programmatically and I am using the below code
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
startActivityForResult(intent, 1);
However the question is How can I select multiple contacts at a time by using a checkbox in the contacts page?
You will have to read the Contacts programmatically and display them in a
ListView
in yourActivity
. UseCheckBox
s in theListView
items and allow multiple items to be selected. Find a simple example/tutorial for aListView
and start from there.There are several reasons why it is better to create a custom
ListView
rather than usingIntent(Intent.ACTION_GET_CONTENT);
:ACTION_GET_CONTENT
, then a chooser will be presented to the user and he will have to select one of those. The user's selection may not support selecting multiple contacts.Here is an example that reads your system contacts: