Android Question making the right app list in intent - help needed

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
this is the code i'm trying to use to send email (below)
and the manifest i use

it is exactly the code (copied) from @Erel 's post
it works perfectly!
one issue - the intent opens all sharing apps not just email apps

that's problematic as users get to click use always and from here on all sharing goes to the email app they chose

how do i make it to show only email apps in the intent list?
what am i doing wrong?

thanks


my click sub

B4X:
Private Sub Button2_Click

    Dim FileName As String = "b4a.png"
    'copy the shared file to the shared folder
    File.Copy(File.DirAssets, FileName, Provider.SharedFolder, FileName)
   
    Dim Email As Email
    Email.To.Add("aaa@bbb.com")
   
    Email.Subject = "subject"
    Email.Body = "This is a test" 'This is the added code
   
    Email.Attachments.Add(Provider.GetFileUri(FileName))
    'Email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment
   
    Dim in As Intent = Email.GetIntent
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    'in.WrapAsIntentChooser("Send Email")
    StartActivity(in)
   
End Sub

manifest - i just changed the target sdk to 34 and left the maxsdk to 18 as it was originally

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.



AddManifestText(<uses-permission
   android:name="android.permission.WRITE_EXTERNAL_STORAGE"
   android:maxSdkVersion="18" />
)

AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)

CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…