1. AndroidManifest에 퍼미션 추가
<uses-permission android:name="android.permission.READ_CONTACTS" /> 추가해주시면 됩니다.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
....
<uses-permission android:name="android.permission.READ_CONTACTS" />
2. JAVA 소스
- 조회할 전화번호를 넣어주면 됩니다.
Uri uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode("전화번호"));
String[] projection = new String[] {ContactsContract.PhoneLookup.DISPLAY_NAME};
String displayName = "";
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
if (cursor != null) {
if (cursor.moveToFirst()){
displayName = cursor.getString(0);
}
cursor.close();
}
'Dev_안드로이드 > 참고소스' 카테고리의 다른 글
가로세로 고정하기 (0) | 2016.08.30 |
---|---|
최근 사용한 앱에서 제외 (0) | 2016.08.30 |
폰전화번호 가져오기 (0) | 2016.08.22 |
안드로이드 앱 개발 할 때 무선 WIFI로 디버깅 하는 방법 (0) | 2016.08.11 |
[Button] 버튼 텍스트가 자동으로 대문자로 보일 때 (0) | 2016.08.10 |