the email app is not opening on my android device. there are no error in code but don't know why app isn't working
Asked
Active
Viewed 30 times
0
-
2Post actual code, not an image. Especially here, the image is too small to read. – Gabe Sechan Apr 03 '22 at 04:30
2 Answers
0
You are using an old or deprecated way to start activity for ACTION_SEND scenarios. Use below snippet for the correct way.
val sendIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, "This is my text to send.")
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent)
You can check out the code snippet and detailed explanation here. https://developer.android.com/training/sharing/send#using-android-system-sharesheet

Mohit Ajwani
- 1,328
- 12
- 24
0
Starting with API level 30, if you're targeting that version or higher, your app cannot see, or directly interact with, most external packages without explicitly requesting allowance.
Check this answer, it works for me.

Ankit
- 335
- 1
- 10