How share a text file with Intent ?

androgene

New Member
Hello,

With the Intent method, I know how to share a text composed with :

B4X:
dim share as intent
share.Initialize(share.ACTION_SEND,"")
share.SetType("text/plain")
share.PutExtra("android.intent.extra.TEXT", mytext)
share.WrapAsIntentChooser("Share text via")
StartActivity(share)

But, how to share a text file (MyFile.TXT) located in DirRootExternal, with the Intent method ?

B4X:
dim i as Intent
dim sFile as String
dim sFullPath as String
dim URI as String
sFile="MyFile.TXT"
sFullPath=File.Combine( File.DirRootExternal ,sFile)
URI =  "file://" & sFullPath
i.Initialize(i.ACTION_SEND, "")
i.SetType("text/plain")
i.PutExtra("android.intent.extra.STREAM", URI) ' < didn't work : how to do ?
i.WrapAsIntentChooser("Share via")
StartActivity(i)

Thank you.
 

barx

Well-Known Member
Licensed User
Longtime User
Could you not just pass the file path / name and use that to open then file?
 
Upvote 0

androgene

New Member
Could you not just pass the file path / name and use that to open then file?
Except if i'm in wrong, share a text file it's like send a text file. So, i'm afraid that your suggest is not in my goal.
In the simple way, i want to send a file, which is a text file, share via intent method.
B4X:
i.PutExtra("android.intent.extra.STREAM", File.DirRootExternal & "/" & sFile) ' < didn't work
i.PutExtra("android.intent.extra.STREAM", "file://" & File.DirRootExternal & "/" & sFile) ' < didn't work

How to do ?
 
Upvote 0

ibra939

Active Member
Licensed User
Longtime User
Is working to share text with any program ?
 
Upvote 0
Top