Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 안드로이드 커스텀 뷰
- 안드로이드 컴포즈
- runCatching
- RecyclerView Sticky Header
- Sticky Header RecyclerView
- 코루틴
- BOJ
- Coroutine
- Android Compose
- 힐트
- Kotlin Serialization
- Android Custom View
- 안드로이드 무한 스크롤
- power menu 라이브러리
- viewmodel
- 코틀린 에러 핸들링
- 코루틴 공식 문서
- Android Compose Navigation
- 스레드 vs 코루틴
- hilt
- android orbit
- android compose orbit
- power menu
- Unsupported metadata version. Check that your Kotlin version is >= 1.0: java.lang.IllegalStateException
- 백준
- Hilt 에러
- AAC ViewModel
- Thread vs Coroutine
- 코루틴 공식문서
- 백준 2615
Archives
- Today
- Total
Beeeam
Android Email Intent 본문
개발자가 자신이 배포한 앱에 대해서 사용자들과 소통할 수 있는 방법은 많이 없다. Play Store에서 댓글로 소통하거나 email을 주고 받아야 한다. 앱 안에 문의하기 기능을 넣어 바로 개발자에게 Email을 보낼 수 있으면 참 편리할 것이다.
그럼 간단하게 앱에서 정해진 email 주소로 메일을 보낼 수 있는 방법을 알아보자.
Intent를 사용하면 간단하게 구현 가능하다.
layoutMoreContact.setOnClickListener {
val email = Intent(Intent.ACTION_SEND)
val receiverEmail = "abc@example.com"
email.data = Uri.parse("mail to:")
email.type = "text/plain"
email.putExtra(Intent.EXTRA_EMAIL, arrayOf(receiverEmail))
email.putExtra(Intent.EXTRA_TEXT, "문의할 내용 적어주세요~~")
startActivity(email)
}
먼저 Intent는 ACTION_SEND로 설정한다.
email.data는 Intent를 사용하여 액티비티를 실행하기 전에 어떤 종류의 데이터를 다루는지 알려준다. 여기에 Uri.parse("mail to:") 이와 같이 설정하면 email 클라이언트를 열게된다. type을 통해서 일반적인 텍스트 타입의 데이터를 다루는 것을 나타낸다.
putExtra 함수를 사용하면 디폴트 값을 설정해놓을 수 있다. 그래서 위의 코드를 실행하면 받는 사람의 메일과 내용이 미리 들어가 있게 된다. Intent.EXTRA_~~ 키와 이에 해당 하는 값으로 선언할 수 있다.
예를 들어 email.putExtra(Intent.*EXTRA_SUBJECT*, "이메일 테스트 제목") 이 처럼 선언하면 email의 제목에 “이메일 테스트 제목”이라는 텍스트가 들어가 있게 된다.
'Android' 카테고리의 다른 글
RecyclerView 마스터하기 (1) | 2023.11.24 |
---|---|
Android CountDownTimer (0) | 2023.11.07 |
무한 스크롤 (0) | 2023.09.18 |
RecyclerView 오류 해결 과정.. (0) | 2023.08.08 |
Power Menu (0) | 2023.06.27 |