2
  1. I want to open Contacts pick activity from my application with search field should be filled programmatically. Can anyone suggest what URI shoud i use or anything to put in intent's extra?

    private static final int PICK_CONTACT_SUBACTIVITY = 2;
    private void startContactActivity() {
        Uri uri = Uri.parse("content://contacts/people");
        // Here in this normally we pass number e.g. Uri.encode("987") but i want to pass name as filter is it possible?
        // I have also tried 
        //uri = Uri.withAppendedPath(android.provider.ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode("pra"));
        //uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode("pra"));
        uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode("pra"));
    
        Intent intent = new Intent(Intent.ACTION_PICK, uri);
        startActivityForResult(intent, PICK_CONTACT_SUBACTIVITY);
    }
    

Can anyone suggest how can i achieve this?

Mihir
  • 179
  • 3
  • 11

2 Answers2

0

You can follow : how-to-pick-contact-number-from-phone-book-of-android-in-to-my-application or developer.android.com/training/contacts-provider/modify-data

Community
  • 1
  • 1
  • Hi omor4android i just want select contacts activity with its search field should be filled with whatever the filter i set programmatically. – Mihir Apr 21 '14 at 12:17
0

It seems that it is not possible to specify a filter programmatically.

The Android SDK documentation states (in the chapter "Retrieval and modification with intents") that for ACTION_PICK you can only use one of Contacts.CONTENT_URI, Phone.CONTENT_URI, StructuredPostal.CONTENT_URI, Email.CONTENT_URI. This is indirectly a filter (all contacts, all with phone numbers, all with postal address, or all with email), but it is limited to this.

Eirik W
  • 3,086
  • 26
  • 29