Is there a way to filter the contacts by "organization" in the contacts calendar of Android, when triggered through another activity?

1

In an Android application, I want to open the contacts directory from another Activity via Intent , but I would like to see only the contacts that have a specific value in the "Organization" field. Is there a way to specify this in Intent that opens the contacts calendar? The current code, where Intent is started when you click the getContactDetails button:

getContactDetails.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        //Inicia atividade de lista de contatos, para obter os dados do contato
        Intent intent = new Intent(Intent.ACTION_PICK,
                                   ContactsContract.Contacts.CONTENT_URI);
        startActivityForResult(intent, PICK_CONTACT);
    }
});
    
asked by anonymous 25.03.2014 / 18:04

2 answers

1

Exactly this you can do as the operation is done in any database in android.

String[] projection = new String[]{Calls.NUMBER, Calls.DURATION};
Cursor cur = context.getContentResolver().query(Calls.CONTENT_URI, projection, null, null, Calls.DATE +" desc");

In the above example I'm picking up the links in my case, as you need the contacts just change something like:

Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null, null); 
    
26.03.2014 / 13:17
0

You have, here is a more detailed example you can order for any field you want

link

Below is an excerpt from the documentation quoted above.

Define the sort order

Defines the sort order for the returned Cursor. Since you're retrieving a specific data type, omit the sort on MIMETYPE. Instead, if the type of detail you're searching for includes a subtype, sort on it. For example, for email you can sort on Email.TYPE:

private static final String SORT_ORDER = Email.TYPE + " ASC ";
    
25.03.2014 / 18:17