1

我正在尝试从电话中获取联系人号码,这是我的查询,但问题是我得到的联系人姓名很少,根本没有电话号码。谁能告诉我如何过滤掉没有联系电话的联系人?

Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
    ContactsContract.Contacts._ID,       
    ContactsContract.Contacts.DISPLAY_NAME,
    ContactsContract.Contacts.PHOTO_ID

    };
String selection = 
    ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +1+"'";

String sortOrder =  ContactsContract.Contacts.DISPLAY_NAME+ " COLLATE LOCALIZED ASC";
4

2 回答 2

1

ContactsContract.Contacts.HAS_PHONE_NUMBER添加到您的选择字符串。

因此,您的代码变为:

String selection = 
    ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +1+"'"
    + " AND " + ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '" +1+"'";
于 2013-06-10T19:33:25.160 回答
1
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +1+"' AND "
                   ContactsContract.Contacts.HAS_PHONE_NUMBER + " = '" +1+"'";
于 2013-06-10T19:32:32.130 回答