Android Question [SOLVED] File provider - question

TomKluz

Active Member
Licensed User
I am studing File Provider example because I would like to share files between apps or eventually send email with attached file.

Partial code from FileProvider example:
Private Sub btnSendEmail_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.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
    StartActivity(in)
End Sub

My question is about SharedFoulder. Actually I cant find it in my phone. Where it is ?
Thanks in advance.
 

DonManfred

Expert
Licensed User
Longtime User
The example in the FileProvider Thread does show how to send an email with Attachment.
If you do not want o use an Intent then all you can do is to use SMTP.
With your credentials hardcoded. Or even with different usernames for each customer. This is more work though.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You can even create a Server app (with B4J or any other language you prefer) on your server which is listen to requests.
You send the email then from your server (you dont have to put credentials in your app as they are stored on the server).
 
Last edited:
Upvote 0

TomKluz

Active Member
Licensed User
Hi DonManfred.
Your presentation of the case is very comprehensive and..I appreciate it very much.
All af things I am trying to do has to be as simple as possible. App is already a complication. So far was going good but Android 14 has change the case.
After overtaking a Bluetooth permissions this problem with disk space access is even worse.
I am going to play more with FileProvider example and in the meantime will try to come up with an action plan.
Hoping it will come. Thank you again for your mental support. I will inform you about progress
 
Upvote 0

TomKluz

Active Member
Licensed User
Hi everyone.
I have been trying few days with no result and finally prepared an example which only creates a little text file , saves and send by Gmail as attachment. Obviously example is based on Erel example (https://www.b4x.com/android/forum/threads/class-fileprovider-share-files.97865/#content). It is working well so I have found a solution in my app. It is also ok now. I am attaching my example. Maybe it will be useful for someone.
 

Attachments

  • Email_sending.zip
    11.2 KB · Views: 37
Upvote 0
Top