Select multiple contacts in Android

Is there an ACTION_PICK way to select multiple contacts from the address book and then return to the previous activity?

+4
source share
1 answer

Not a complete answer, but perhaps useful:

// Let user select (multiple) from a list of contacts with email addresses Intent i = new Intent(Intent.ACTION_GET_CONTENT, Email.CONTENT_URI); startActivityForResult(Intent.createChooser(i, ""), MY_RESULT_1); 

In onActivityResult, you apparently just get a Uri (in data.getData ()), which represents the entire set of contacts. Excellent.

On HTC Desire / Froyo, data.getExtras () contains three lists of ArrayLists, one of which seems to contain the identifier of the records selected by the user.

 Set<String> keys = data.getExtras().keySet(); ArrayList<Integer> ids = null; for (String s : keys) { Object o = data.getExtras().get(s); if (o instanceof ArrayList) { ArrayList a = (ArrayList) o; if (a.size() > 0 && a.get(0) instanceof Integer) { ids = a; } } } 

You can use them to filter the result of the query request data.getData () Uri.

Not really, and maybe HTC. You can vary.

If someone can point out a smarter way, I'm a happy listener :)

+1
source

Source: https://habr.com/ru/post/1314285/


All Articles