Is there开发者_如何学Python a way similar to ACTION_PICK to select multiple contacts from the address book and then return to previous activity?
Not a full answer, but maybe helpful anyway:
// 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'll apparently just get a Uri (in data.getData()) that represents the entire set of contacts. Great.
On HTC Desire/Froyo, data.getExtras() contain three ArrayLists, one of which seems to hold the Id's of the records the user selected.
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 these to filter the result from querying the data.getData() Uri.
Not pretty, and possibly HTC specific. You mileage may vary.
If someone can point out a smarter way, I'm a happy listener :)
精彩评论