Itβs easy to open the Android Contact app to show all the contacts and select one of them:
In action:
private int PICK_CONTACT = 853456; // ... // open contact list void openContactPicker() { Intent it= new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); startActivityForResult(it, PICK_CONTACT); } // when back from intent: use pick result @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // ... switch (requestCode) { case PICK_CONTACT: if (dataOk(data)) { extractContactInfo(data); } else { showErrorMessage(); } break; // ... }
But is it possible to set some filtering criteria, so that the Contact application will display only those contacts that have the specified elements - for example. full postal information or corresponding email or phone number?
My application needs email information, the current implemented workflow is as follows:
- User presses a button to open contacts
- App contact opens, all contacts are displayed
- user selects one
- In my activity, contact is checked
- Available postal information β do the right thing
- mail information not available β message field
Since many contacts do not have mail information, in most cases the message box "Sorry, no mail information available for this contact" will be displayed. This is not acceptable behavior.
One option β I just implement this β is to query the contacts database inside the application and filter in my own code, but using this approach has some consequences:
- the application requires permission to read contacts, which may not be for many users.
- a contact picker should be implemented that may be different from the one the user is familiar with
So, setting some criteria for the Contacts app looks a lot more elegant.
The application should run on Android 2.3.3 and higher.
Questions:
- Is it possible for 2.3.3 to specify filtering criteria (especially, for example, "has_postal_information") for the Contacts application when it is launched through startActivityForResult?
- If not: is this possible on later versions of the OS?
source share