Android Question How to share image file to Facebook's Messager?

Theera

Well-Known Member
Licensed User
Longtime User
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.
 

Attachments

  • TestShareLib.zip
    29.8 KB · Views: 40

Theera

Well-Known Member
Licensed User
Longtime User
I've tried another strategy (Using intent) ,it is still not worked for me again.
B4X:
    Dim u As Uri 'ContentResolver library
    File.Copy(File.DirAssets, "logo.png", File.DirDefaultExternal, "logo.png")
    'u.Parse("file://" & File.Combine(PicDir, "tmpfile.jpg"))
    u.Parse("file://" & File.Combine(File.DirDefaultExternal,"logo.png"))
    in.PutExtra("android.intent.extra.STREAM",u)
    in.SetType("image/*")
    in.WrapAsIntentChooser("Share Via")
    StartActivity(in)
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
I made it this way (email version)

B4X:
    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("[email protected]")
    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 * [email protected]")
    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)
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I made it this way (email version)

B4X:
    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("[email protected]")
    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 * [email protected]")
    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)
Thank you for reponse. I'm looking for send image to only facebook messenger. Assume I and another one are connected via facebook messenger
 
Upvote 0
Top