안드로이드
[안드로이드기초] 암시적인텐드 ACTION_DIAL Exception
dreamstalker
2017. 5. 9. 14:57
안드로이드에서 암시적인텐트를 사용하여 전화걸기를 하려고 할 때
아래처럼 코드를 넣는다. 전화번호는 물론 예시다..
Uri uri = Uri.parse("tel :010-1234-5678");
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);
문제가 없을 것 같아서 실행 했는데 오류가 발생하여
앱이 중지되면서 Logcat에 빨갛게 에러 로그가 보여진다면..ㅠㅠ
(android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.DIAL dat=tel :010-1234-5678 })
로그캣에서 에러
아래와 같이 수정한다.
Uri uri = Uri.parse("tel:010-1234-5678");
Intent intent = new Intent(Intent.ACTION_DIAL, uri);
startActivity(intent);
원인은 황당하게도 tel과 콜론(:) 사이의 공백때문이다.
"tel :010-1234-5678"
공백을 넣지 않도록 해야겠다..