【问题标题】:How to programmatically open contacts pick with search filter entered programmatically?如何使用以编程方式输入的搜索过滤器以编程方式打开联系人选择?
【发布时间】:2014-04-21 11:42:48
【问题描述】:
  1. 我想从我的应用程序中打开联系人选择活动,搜索字段应以编程方式填写。 任何人都可以建议我应该使用什么 URI 或任何额外的东西吗?

    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);
    }
    

谁能建议我如何做到这一点?

【问题讨论】:

    标签: android contacts android-contacts intentfilter contactscontract


    【解决方案1】:

    【讨论】:

    • 嗨 omor4android 我只想选择联系人活动及其搜索字段应该填充我以编程方式设置的任何过滤器。
    【解决方案2】:

    似乎无法以编程方式指定过滤器。

    Android SDK documentation states (in the chapter "Retrieval and modification with intents") ACTION_PICK 只能使用其中之一 Contacts.CONTENT_URIPhone.CONTENT_URIStructuredPostal.CONTENT_URIEmail.CONTENT_URI。这间接是一个过滤器(所有联系人、所有电话号码、所有邮政地址或所有电子邮件),但仅限于此。

    【讨论】:

      猜你喜欢
      • 2014-06-29
      • 1970-01-01
      • 1970-01-01
      • 2016-12-26
      • 2018-08-25
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      相关资源
      最近更新 更多