가장 많이 본 글

2013년 12월 2일 월요일

Android - 다이얼 or 전화걸기 ( Dial or Call )


Android 에서 다이얼 또는 전화걸기 기능을 알아보겠습니다.


1. 다이얼
    :) 전화번호를 표시만 해주는 기능.
   
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:010-1111-2222"));
    startActivity(intent);
    




2. 전화걸기
    :) 전화를 즉시 걸어주는 기능.

    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:010-1111-2222"));
    startActivity(intent);




참고로 AndroidManiFest.xml 파일에 아래의 퍼미션을 추가해 줘야 합니다.
<uses-permission android:name="android.permission.CALL_PHONE" />


댓글 3개:

  1. Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:010-1111-2222"));
    startActivity(intent); <<<<<-------------- 스타트액티비티 부분 빨간줄 뜨는데 왜 이러는지 아시나요??

    답글삭제
    답글
    1. startactivity는 context 위에서 실행됩니다.

      삭제