이 문제에 관해 많은 질문이 있습니다. 하지만 나에게 도움이되는 것을 찾을 수 없습니다. 는이 코드에 의해 전화 번호가있는 모든 안드로이드 연락처를 얻는 방법을 알고안드로이드에서 현재 연락처를 얻으십시오.
private List fillContactsList() {
List tmpList = new ArrayList();
Cursor c = getContentResolver().query(
ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
while (c.moveToNext()) {
String ContactID = c.getString(c
.getColumnIndex(ContactsContract.Contacts._ID));
String name = c.getString(c
.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String hasPhone = c
.getString(c
.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if (Integer.parseInt(hasPhone) == 1) {
Cursor phoneCursor = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ "='" + ContactID + "'", null, null);
while (phoneCursor.moveToNext()) {
String number = phoneCursor
.getString(phoneCursor
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
con = new Contact();
con.setName(name);
con.setNumber(number);
tmpList.add(con);
}
phoneCursor.close();
}
}
c.close();
Collections.sort(tmpList);
return tmpList;
}
내 장치에서 이것의 결과는 360 연락처하지만 난이 전화를 통해 내 연락처를 열 때 난 그냥 (120) 그래서 어떻게 참조 현재 전화의 연락처 목록에 표시된 그룹 만받을 수 있습니까?
감사합니다. Saar
현재 사용자가 사용중인 필터에 따라 다릅니다. 모든 연락처가 아닌 필터로 연락처를 얻을 수 있습니다 – Spidy