【发布时间】:2015-12-21 14:53:55
【问题描述】:
我有一个 SearchView,如果我在其中键入一个名称,它会显示一个匹配它的名称的自动完成列表。但是,Facebook ambulance 和 AL Cricket 等联系人也会出现在这些结果中。如何排除此类结果并仅获取那些与实际人员有关的联系人?
我用来获取显示名称的代码是这样的:
private String getDisplayNameForContact(Intent intent) {
Cursor phoneCursor = getContentResolver().query(intent.getData(), null, null, null, null);
phoneCursor.moveToFirst();
int idDisplayName = phoneCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
String name = phoneCursor.getString(idDisplayName);
phoneCursor.close();
return name;
}
【问题讨论】: