Android Question Sharing file via Email

DT1111

Member
Licensed User
Longtime User
The following codes work when I want to send files via email but the DirRootExternal path appears in the To: field. Is there a way to prevent that?

B4X:
Dim In As Intent
Dim u As Uri 'ContentResolver library

In.Initialize(In.ACTION_SEND,"file://" & File.Combine(File.DirRootExternal, "test.txt"))
u.Parse("file://" & File.Combine(File.DirRootExternal, "test.txt"))
In.PutExtra("android.intent.extra.STREAM", u)
In.SetType("*/*")
StartActivity(In)

Thanks.
 

DT1111

Member
Licensed User
Longtime User
Hi Erel

I was but I changed to the above code because sometime I want to share files via Bluetooth. The above gives me the options for sharing file.

Is there a workaround to the above minor problem? Thanks.
 
Upvote 0

DT1111

Member
Licensed User
Longtime User
Hi Erel

Thanks and the path still appears in the To: field with someone@abc.com

B4X:
Dim In As Intent
Dim u As Uri 'ContentResolver library

In.Initialize(In.ACTION_SEND,"file://" & File.Combine(File.DirRootExternal, "test.txt"))
u.Parse("file://" & File.Combine(File.DirRootExternal, "test.txt"))
In.PutExtra("android.intent.extra.STREAM", u)
In.PutExtra("android.intent.extra.EMAIL", ArrayAsString("someone@abc.com"))
In.SetType("*/*")
StartActivity(In)

If the following is commented out there was no attachment

B4X:
'In.PutExtra("android.intent.extra.STREAM", u)
 
Upvote 0

DT1111

Member
Licensed User
Longtime User
Hi Erel

OK, the following are changed from

B4X:
Dim In As Intent
Dim u As Uri 'ContentResolver library

In.Initialize(In.ACTION_SEND,"file://" & File.Combine(File.DirRootExternal, "test.txt"))
u.Parse("file://" & File.Combine(File.DirRootExternal, "test.txt"))
In.PutExtra("android.intent.extra.STREAM", u)
In.PutExtra("android.intent.extra.EMAIL", ArrayAsString("someone@abc.com")) '<<======== from
In.SetType("*/*")
StartActivity(In)

to

B4X:
Dim In As Intent
Dim u As Uri 'ContentResolver library

In.Initialize(In.ACTION_SEND,"file://" & File.Combine(File.DirRootExternal, "test.txt"))
u.Parse("file://" & File.Combine(File.DirRootExternal, "test.txt"))
In.PutExtra("android.intent.extra.STREAM", u)
In.PutExtra("android.intent.extra.EMAIL", ArrayAsString("")) '<<======== to
In.SetType("*/*")
StartActivity(In)

If that was what you meant, the path still appears in the To: field which I wanted to remove.
 
Upvote 0
Top