Launching an email client (such as Gmail) directly from an Android button click is implemented using an implicit ACTION_SENDTO Intent pre-populated with recipient emails and subjects.
Kotlin Email Intent Code Example
import android.content.Context
import android.content.Intent
import android.net.Uri
fun sendEmail(context: Context, recipient: String, subject: String) {
val intent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:$recipient")
putExtra(Intent.EXTRA_SUBJECT, subject)
}
if (intent.resolveActivity(context.packageManager) != null) {
context.startActivity(intent)
}
}
Comments and corrections