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





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@example.com"))
in.PutExtra("android.intent.extra.SUBJECT", "this is the subject")
in.PutExtra("android.intent.extra.TEXT", "this is the body")
StartActivity(in)

asales

Expert
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@example.com"))
in.PutExtra("android.intent.extra.SUBJECT", "this is the subject")
in.PutExtra("android.intent.extra.TEXT", "this is the body")
StartActivity(in)

 
Upvote 1
Solution

toby

Well-Known Member
Licensed User
Longtime User
For Gmail app, I need to comment out the following line
B4X:
[CODE=b4x]in.PutExtra("android.intent.extra.EMAIL", Array As String("email@example.com"))
[/CODE]
Otherwise, "email@example.com" would appear as a recipient.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…