나는 서버 측에 안드로이드 장치의 전화 번호부를 업로드하는 앱을 만들고 있습니다. 전화 번호부에 이름을 알 수 있지만 해당 이름의 연락처가 없습니다.android에서 phonebook의 연락처 정보 검색 중
연락처를 얻는 방법은 People.NUMBER
입니다.
나는 서버 측에 안드로이드 장치의 전화 번호부를 업로드하는 앱을 만들고 있습니다. 전화 번호부에 이름을 알 수 있지만 해당 이름의 연락처가 없습니다.android에서 phonebook의 연락처 정보 검색 중
연락처를 얻는 방법은 People.NUMBER
입니다.
확인이 링크 :
How to call Android contacts list?
How to get contacts from native phonebook in android
How to obtain all details of a contact in Android
How to get the first name and last name from Android contacts?
How to import contacts from phonebook to our application
How to get all android contacts but without those which are on SIM
사용이 코드. 이 코드는 컨텍스트 이름과 번호를 Arralist에 저장합니다. 당신이 필요로
ArrayList<HashMap<String,String>> contactData=new ArrayList<HashMap<String,String>>();
ContentResolver cr = getContentResolver();
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
while (cursor.moveToNext()) {
try{
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
String name=cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
String hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if (Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId, null, null);
while (phones.moveToNext()) {
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
HashMap<String,String> map=new HashMap<String,String>();
map.put("name", name);
map.put("number", phoneNumber);
contactData.add(map);
}
phones.close();
}
}catch(Exception e){}
}
는 연락처 데이터 목록을 사용합니다.