Intent intent = new Intent(Intent.ACTION_PICK);
intent.setData(ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, 0);
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (resultCode == RESULT_OK) {
Cursor cursor = null;
if (data != null) {
cursor = getContentResolver().query(data.getData(),
new String[]{ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER}, null, null, null);
}
if (cursor != null) {
cursor.moveToFirst();
Log.e("cursor", "name : " + cursor.getString(0));
Log.e("cursor", "number : " + cursor.getString(1));
cursor.close();
}
}
super.onActivityResult(requestCode, resultCode, data);
}