我想从我的应用程序打开联系人选择活动,搜索字段应该以编程方式填写。 任何人都可以建议我使用什么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);
}
任何人都可以建议我如何实现这一目标?
答案 0 :(得分:0)
您可以关注: how-to-pick-contact-number-from-phone-book-of-android-in-to-my-application 要么 developer.android.com/training/contacts-provider/modify-data
答案 1 :(得分:0)
似乎无法以编程方式指定过滤器。
ACTION_PICK
,Contacts.CONTENT_URI
你只能使用其中一个
Phone.CONTENT_URI
,StructuredPostal.CONTENT_URI
,Email.CONTENT_URI
,setTimeout
。这是间接过滤器(所有联系人,所有联系人都有电话号码,都有邮政地址,或全部都有电子邮件),但仅限于此。