In Android 12 if you add informations as subject(EXTRA_SUBJECT
) and message(EXTRA_TEXT
) when you use ACTION_SENDTO
Intent to send a text email, these don't appear in the email client message, contrarely to all previous versions.
An user in a similar Kotlin question seems has solved the problem using apply selector in this way:
private fun createIntent(
metadata: String
): Intent {
return Intent(ACTION_SEND)
.putExtra(
EXTRA_EMAIL,
arrayOf(EMAIL)
)
.putExtra(
EXTRA_SUBJECT,
TITLE
)
.putExtra(
EXTRA_TEXT,
metadata
)
.apply {
selector = Intent(ACTION_SENDTO).setData(Uri.parse("mailto:"))
}
}
What is the reason of this issue? What is the proper way to fix the issue in Java?