Android Question How to show only email apps when sharing text via intent

toby

Well-Known Member
Licensed User
Longtime User
This is the code I use to share some text via email:
Code I use to share text via email:
Public Sub shareAppByEmail(subject As String, body As String)
    Dim in As Intent
    'Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));
    in.Initialize(in.ACTION_SEND, "")
    in.putExtra("android.intent.extra.SUBJECT", subject)
    in.PutExtra("android.intent.extra.TEXT", body)
    in.SetType("text/plain")
    in.WrapAsIntentChooser("Share Via")
    StartActivity(in)
End Sub



share by email apps only.jpg


When the code is executed, above screen appears; as you can see, a lot of apps are shown. What can I do so that only email apps (Gmail and Email) show up?

TIA
 
Solution
B4X:
Dim in As Intent
in.Initialize("android.intent.action.SENDTO", "mailto:")
in.PutExtra("android.intent.extra.EMAIL", Array As String("[email protected]"))
in.PutExtra("android.intent.extra.SUBJECT", "this is the subject")
in.PutExtra("android.intent.extra.TEXT", "this is the body")
StartActivity(in)

1656985235315.png

toby

Well-Known Member
Licensed User
Longtime User
B4X:
Dim in As Intent
in.Initialize("android.intent.action.SENDTO", "mailto:")
in.PutExtra("android.intent.extra.EMAIL", Array As String("[email protected]"))
in.PutExtra("android.intent.extra.SUBJECT", "this is the subject")
in.PutExtra("android.intent.extra.TEXT", "this is the body")
StartActivity(in)
For Gmail app, I need to comment out the following line
B4X:
[CODE=b4x]in.PutExtra("android.intent.extra.EMAIL", Array As String("[email protected]"))
[/CODE]
Otherwise, "[email protected]" would appear as a recipient.
 
Upvote 0
Top