버튼 클릭시 연락처 전화 번호를 클릭 한 다음 EditText로 전송할 수 있지만 국가 코드없이 결과 만 받고 싶습니다. 예 : +33 xx xx xx xxx becomes xx xx xx xxx
연락처에서 번호 선택하기 국가 코드 제거
내가이 방법을 사용할 수 있습니까?
버튼 클릭 :
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
intent.setType(CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if ((requestCode == 1) && (resultCode == RESULT_OK)) {
Cursor cursor = null;
try {
Uri uri = data.getData();
cursor = getContentResolver().query(uri, new String[] { CommonDataKinds.Phone.NUMBER }, null, null, null);
if (cursor != null && cursor.moveToNext()) {
String phone = cursor.getString(0);
editText.setText(phone);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
답변 주셔서 감사합니다. 그러나 작동하지 않습니다. –