我有代码 java android studio 可以在 hp 中显示列表联系人,并且已获得许可,但它在 sdk > 27 中不起作用(空白值)有人帮助我吗?这是我的代码
contactModelArrayList = new ArrayList<>();
Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'",
null,
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME+" COLLATE LOCALIZED ASC");
while (phones.moveToNext())
{
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
ContactModel contactModel = new ContactModel();
contactModel.setName(name);
contactModel.setNumber(phoneNumber);
contactModelArrayList.add(contactModel);
Log.d("name>>",name+" "+phoneNumber);
}
Log.d("phones", phones.toString());
phones.close();
contactAllAdapter = new ContactAllAdapter(this,contactModelArrayList);
listView.setAdapter(contactAllAdapter);
在 logcat 中什么都没有
慕的地6264312
蛊毒传说
慕娘9325324
随时随地看视频慕课网APP
相关分类