Android Question Call to EMail service now includes choices

Cliff McKibbin

Member
Licensed User
I have been using the capability to start an email and attach a file to it for some time. The original post I used was:


My logic using the methods in the forum entry is:
B4X:
Sub btSend_Click
    Dim email As Email
 
    ' setup email body message
    s = "This file was sent to you from the " & Starter.AppName & " App by" & starter.ssyname & CRLF
    S=s & "This is a file of one of your listings." & CRLF
    S=s & "You can double click it and print all or part of it or save it as you wish."
       
    Dim FileName1 As String = Starter.FS92File
  
    'copy the file to the shared folder
     File.Copy(File.Dirinternal, FileName1, Starter.Provider.SharedFolder, FileName1)
    
    ' build the email message
    email.To.Add(txEmail.Text)
    email.Subject = "Listing from the " & Starter.AppName & " App" 
    email.Body=s
    email.Attachments.Add(Starter.Provider.GetFileUri(FileName1))
       
    Dim in As Intent = email.GetIntent
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    StartActivity(in)
End Sub

The logic originally immediately fired my android email app and allowed me to add more addresses or touch the arrow at the top right to send the email.

Some time ago, I noticed that a 'choice' box now appears at the bottom of the screen essentially asking what method I want to choose to 'share' my info. The box included 'EMail', 'gmail', 'drive', 'bluetooth', 'nearby share', 'Samsung Cloud Drive', 'Skype', 'Wifi Direct'. I always choose 'email' and the program proceeds as it used to.

My question is: "Is there any way to modify my 'call' to the email to avoid this 'choice' box. It might be an option on the in.flags.
As an alternative "Is there some choice in android setup to eliminate the extra step". The disadvantage of this is that the user would have to make that change.

Thanks, Cliff McKibbin
 

Cliff McKibbin

Member
Licensed User
Erel, Thanks for the update. I'll leave it alone.
Thanks for B4A 11.50. It works great and is definitely faster compiling.
Cliff McKibbin
 
Upvote 0

Cliff McKibbin

Member
Licensed User
After thinking I would not worry about the extra step to choose a 'share' method as described above, I happened to notice that only my emails of the database for file backup were causing this extra step (FS92Switch=1). When I sent a txt or pdf file I am not getting the 'share choice'.

In looking at my code, the big difference is that with the database backup, I include a txt file with the 'Restore Instructions' when FS92Switch=1 as displayed in the code below. Note that I had simplified the code above so as not to confuse by leaving out the code for the 2nd attachment. As it turns out, someone might have noticed the 2nd attachment and pointed the answer out.

B4X:
' build the email message
    Dim email As Email
   
    email.To.Add(txEmail.Text)
    If Starter.FS92Switch=1 Then email.Subject = "Backup Copy of " & Starter.DBName
    If Starter.FS92Switch=2 Then email.Subject = "Help file from the " & Starter.AppName & " App "
    If Starter.FS92Switch=3 Then email.Subject = "Listing from the " & Starter.AppName & " App"
    If Starter.FS92Switch=4 Then email.Subject = FileName1 & " file from the " & Starter.AppName & " App "
   
    email.Body=s
    email.Attachments.Add(Starter.Provider.GetFileUri(FileName1))
    If Starter.fs92switch=1 Then
        email.Attachments.Add(Starter.Provider.GetFileUri(FileName2))
    End If
   
   
    Dim in As Intent = email.GetIntent
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    StartActivity(in)
When I comment out the code for the 2nd attachment, the process goes directly to the email handler.
When I leave it in, the process requires that I make the choice of 'share' apps.

The question now becomes: "Is there a way to eliminate the 'choice' step when adding the 2nd attachment?
 
Upvote 0
Top