2

我希望根据一组电话号码检索联系人列表。这里出了什么问题?

目前使用这个 -

private String numbers = "'12345', '54321'";

String[] mSelectionArgs = {numbers};'

return new CursorLoader(getActivity(),
                    PhoneLookup.CONTENT_FILTER_URI,
                    ContactsQuery.PROJECTION,
                    ContactsQuery.SELECTION,
                    mSelectionArgs,
                    PhoneLookup.DISPLAY_NAME);

PROJECTION 和 SELECTION 在 ContactsQuery 中定义如下

final static String[] PROJECTION = {
        PhoneLookup._ID,

        PhoneLookup.LOOKUP_KEY,

            PhoneLookup.DISPLAY_NAME,

            PhoneLookup.PHOTO_THUMBNAIL_URI,

    };

final static String SELECTION =     
            PhoneLookup.HAS_PHONE_NUMBER + "=1 AND " + PhoneLookup.NUMBER) + " IN (?)";

但是,我收到错误:

07-08 00:44:21.007: E/AndroidRuntime(2307): 由: java.lang.IllegalArgumentException: URI: content://com.android.contacts/phone_lookup, 调用用户: com.example.android.contactslist,调用包:com.example.android.contactslist

4

1 回答 1

0

Try:

ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, (DISPLAY_NAME = '" + name + "'"), null, null);

于 2013-07-07T21:11:52.517 回答