티스토리 뷰
Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.
Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.
아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.
Show compose SMS view in Android
안드로이드에서 SMS 작성 화면을 보여주는 방법
문제 내용
I want to send a sms with Android.
안드로이드에서 SMS를 보내고 싶습니다.
What is the intent for SMS sending?
SMS를 보내기 위한 intent는 무엇인가요?
I want to show the compose sms view with my pre-define text passing over in message field.
미리 정의된 텍스트가 메시지 필드에 전달되는 SMS 작성 화면을 보여주고 싶습니다.
높은 점수를 받은 Solution
You can use the following code:
다음 코드를 사용할 수 있습니다:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("sms:"
+ phoneNumber)));
Make sure you set phoneNumber
to the phone number that you want to send the message to
phoneNumber를 메시지를 전송하려는 전화번호로 설정해야 합니다.
You can add a message to the SMS with (from comments):
(댓글에서 가져온 내용입니다) SMS에 메시지를 추가하려면 다음과 같이 할 수 있습니다:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber));
intent.putExtra("sms_body", message);
startActivity(intent);
가장 최근 달린 Solution
This allows to send text message through existing app. phoneNumber - is String. If you do not wish to specify phone number, use empty string "".
이는 기존 앱을 통해 문자 메시지를 보낼 수 있게 해줍니다. phoneNumber은 문자 메시지를 보낼 전화번호로, 전화번호를 지정하지 않으려면 빈 문자열 ""을 사용하면 됩니다.
Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("smsto", phoneNumber, null));
sendIntent.putExtra("sms_body", "text message");
startActivity(sendIntent);
출처 : https://stackoverflow.com/questions/4967448/show-compose-sms-view-in-android
'개발 > 안드로이드' 카테고리의 다른 글
WebView 에서 파일 다운로드하기 (0) | 2023.02.25 |
---|---|
액티비티 시작 시 키보드가 표시되지 않도록 하기 (0) | 2023.02.25 |
안드로이드 RecyclerView에서 아이템 추가 및 삭제 (0) | 2023.02.24 |
RecyclerView에서 빈 뷰 표시하기 (0) | 2023.02.24 |
java.lang.NullPointerException: 'android.view.View.getImportantForAccessibility()' 메소드를 null 객체 참조에서 호출하려고 시도했습니다. (0) | 2023.02.23 |