티스토리 뷰

반응형

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

반응형
댓글
공지사항
최근에 올라온 글