Assume I have qrcode image in ImageView1 ,I would like to share it to someone's messager.
So then I have studied SSg's share image strategy. I try to code as fallowing his guide , but it isn't worked for me.
Dim FileName As String = "Testbild.jpg"
'copy the shared file to the shared folder
File.Copy(File.DirAssets, FileName, Provider.SharedFolder, FileName)
Dim email As Email
email.To.Add("tester@test.com")
email.Subject = "subject"
email.Attachments.Add(Provider.GetFileUri(FileName)) 'first attachment
email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment
Dim in As Intent = email.GetIntent
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)
and here a way to share a textfile:
B4X:
Dim FileToSend As String = "Visitenkarte.txt"
File.WriteString(Provider.SharedFolder, FileToSend, "Tester Testman * Teststreet 1 * 12345 MyCity * +49 xxxxx xxxxxx * tester@test.com")
Dim in As Intent
in.Initialize(in.ACTION_SEND, "")
in.SetType("text/plain")
in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(FileToSend))
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)
Dim FileName As String = "Testbild.jpg"
'copy the shared file to the shared folder
File.Copy(File.DirAssets, FileName, Provider.SharedFolder, FileName)
Dim email As Email
email.To.Add("tester@test.com")
email.Subject = "subject"
email.Attachments.Add(Provider.GetFileUri(FileName)) 'first attachment
email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment
Dim in As Intent = email.GetIntent
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)
and here a way to share a textfile:
B4X:
Dim FileToSend As String = "Visitenkarte.txt"
File.WriteString(Provider.SharedFolder, FileToSend, "Tester Testman * Teststreet 1 * 12345 MyCity * +49 xxxxx xxxxxx * tester@test.com")
Dim in As Intent
in.Initialize(in.ACTION_SEND, "")
in.SetType("text/plain")
in.PutExtra("android.intent.extra.STREAM", Provider.GetFileUri(FileToSend))
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
StartActivity(in)