1

嗨,实际上我这样做是为了获取所有有号码的联系人:

String[] projecao = new String[] { ContactsContract.Contacts._ID,
                ContactsContract.Contacts.LOOKUP_KEY,
                ContactsContract.Contacts.DISPLAY_NAME };
        String selecao = ContactsContract.Contacts.HAS_PHONE_NUMBER + " = ? ";
        Cursor contatos = contexto.getContentResolver().query(
                ContactsContract.Contacts.CONTENT_URI, projecao, selecao,
                new String[] { "1" }, null);

并获取每个联系人的所有号码:

while (contatos.moveToNext()){
    Cursor numbers = contexto
                    .getContentResolver()
                    .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                            new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER },
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                    + " = ?",
                            new String[] { contatos.getString(contatos
                                    .getColumnIndex(ContactsContract.Contacts._ID)) },
                            null);
    numbers.moveToFirst();
    StringBuilder sb = new StringBuilder();
                do {
                    sb.append(numbers.getString(numbers
                            .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))
                            + ", ");
                } while (numbers.moveToNext());
}

但我不能选择来自 facebook 的号码。

我收到该错误:索引 0 请求。此错误是因为光标编号与任何编号都不匹配。

4

1 回答 1

1

您是否专门尝试从 Facebook 联系人中获取电话号码?

FaceBook 内容提供商受到限制。它不会让您检索电话号码。

请参阅此问题此处此处

于 2012-12-05T22:24:14.277 回答