Experiencing some strange behaviour when trying to pick a contact and return it to my activity. Everything works except I'm seeing some contacts which should not be displayed. e.g. people I'm following on twitter but have no other interaction with. I understand why these records exist in the database, but they don't show when I click on 'People' and run the default contact manager app on the phone so they shouldn't show when I ask my app to display a list of people to pick from?
The strangest thing of all is that if I type a letter to filter the list (e.g. hit 'A' to show all contacts containing 'A') and then hit backspace (so I'm now showing all entries again) the phantom contacts disappear!
Any ideas anyone? I really don't want have to be bothered writing my own 'Select a Contact' activity. Code (pretty basic) shown below:
public void launchContactPicker() {
// Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode("steve"));
Uri uri = ContactsContract.Contacts.CONTENT_URI;
Toast.makeText(this, "Contacts uri = [" + uri +"]", Toast.LENGTH_SHORT).show();
try {
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, uri);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
}
catch (Exception e) {
Toast.makeText(this, "Exception: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
I have also tried requesting a filtered list of contacts (thought maybe using this and wildcarding might do the trick) but haven't managed to get that working at all. Seems the ACTION_PICK intent isn't designed to work with this sort of Uir?