B4A Library Share Library - Beta!

Hi folks,

This has been raised many times on the forum, unfortunately the intent library in B4A seems to have problems placing images as attachment.

Please find attached a new share library.

This library has the option to show the share window, and I've tested it works with following:

Facebook
Twitter
Messaging
Picasa
WhatsApp
Email client

It does not work with the default GMail (Google Mail) app. I've searched online and it is an issue with GMail app itself I think (many people have raised similar issue). Will keep looking for a solution.

It also lessens down the share code for images to 2 lines :D

I need your help in testing this library!

Please feedback whether it works or not.

Sample code:

B4X:
Dim share As MESShareLibrary
share.sharebinary("file:/" & File.DirDefaultExternal & "/Image1.png", "image/png", "Do you see this?")

Enjoy!

-Bill
 

Attachments

  • MESShareLibrary.zip
    2.5 KB · Views: 2,094
Last edited:

Omar

Member
Licensed User
Longtime User
Thanks for your help.

I am quite sure that I did use the updated library, but will check again shortly and report back. Really appreciate your efforts and assistance.
 

Quillok

Member
Licensed User
Longtime User
Hey,

I've got a little problem. I think it's totally easy to solve but I don't get the solution. How can I share an image thats in File.DirAssets?

Tried this:
B4X:
share.sharebinary("file://" & File.DirAssets & "/testimage.png", "image/png", "Test1","Test2")

But when I try to share it on facebook the image is not shared. Is it not possible to use the files of File.DirAssets or am I doing something wrong?

And btw the examplecode in the first post is'nt up2date :)
 

ssg

Well-Known Member
Licensed User
Longtime User
Hey,

I've got a little problem. I think it's totally easy to solve but I don't get the solution. How can I share an image thats in File.DirAssets?

Tried this:
B4X:
share.sharebinary("file://" & File.DirAssets & "/testimage.png", "image/png", "Test1","Test2")

But when I try to share it on facebook the image is not shared. Is it not possible to use the files of File.DirAssets or am I doing something wrong?

Hi,

I am afraid this library cant share asset folder files.. there might be a workaround here. That will need some extra coding stuff.

An alternative is you could load the image from the asset folder and save into a temporary file and then share the temporary file.

And btw the examplecode in the first post is'nt up2date :)

Welcome to my world! :D

Cheers!
-Bill
 

susu

Well-Known Member
Licensed User
Longtime User
Bill, I need some help! :D

I want to share a picture from DirAssests so I copy it to DirInternal but I can't share it to Facebook. My code:

B4X:
If File.Exists(File.DirInternal, "share.jpg") Then
   File.Delete(File.DirInternal, "share.jpg")
End If
   
File.Copy(File.DirAssets, "1.jpg", File.DirInternal, "share.jpg")

Dim share As MESShareLibrary
share.sharebinary("file:/" & File.DirInternal & "/share.jpg", "image/png", "Share", "From my Android.")
 

susu

Well-Known Member
Licensed User
Longtime User
Yes, I changed to "file://" but still no luck.
 

Jaames

Active Member
Licensed User
Longtime User
Hi ssg

Is it problem to add "share via bluetooth" in this library ?

and for the lib - :sign0098:
 

ssg

Well-Known Member
Licensed User
Longtime User
susu,

Maybe the type is wrong?

Try changing "image/png" to "image/jpg" or "image/jpeg". I havent tested these yet. Hope this will solve the problem...

Otherwise I will need to revisit this library. :p

Jaames,

share via bluetooth, I have not tested, but I think it should work.

Cheers!
-Bill
 

Jaames

Active Member
Licensed User
Longtime User
Share via Bluetooth is working

share via bluetooth, I have not tested, but I think it should work.

I tested it and it is working, and Gmail is working also ;)

Thanks for this great lib 5+ :)
 

susu

Well-Known Member
Licensed User
Longtime User
Hi Bill,

I tried "image/jpeg" and "image/jpg" but it doesn't work :(
 

ssg

Well-Known Member
Licensed User
Longtime User
Hi susu...

Hmm... after you copy the image, are you able to access it by exploring to the folder where the file is located? Just wondering if access to internal folders is allowed by external apps.

Cheers!
-Bill
 

susu

Well-Known Member
Licensed User
Longtime User
Hi Bill,
You're right. I copy to DirDefaultExternal and it worked! Now I can share to Facebook but without message text. Do you have any idea?
 

ssg

Well-Known Member
Licensed User
Longtime User
Hi Bill,
You're right. I copy to DirDefaultExternal and it worked! Now I can share to Facebook but without message text. Do you have any idea?

Hi susu,

No idea on the text part for facebook, somehow it is not working, tried a number of things, but just wouldn't work...

:sign0148:
 

susu

Well-Known Member
Licensed User
Longtime User
Thank you Bill. I noticed my app add "Write to SD card" permisson when I copy file to DirDefaultExternal. Maybe it'll scare my user but it's worth :D
 

ssg

Well-Known Member
Licensed User
Longtime User
Most of the time, if you write an explanation on why that permission is there, users will understand.

But then again, very often users dont even check permissions :D

Good luck!
 

susu

Well-Known Member
Licensed User
Longtime User
Good news! It can share to Gmail :D
 

DevBaby

Active Member
Licensed User
Longtime User
Hi susu,

No idea on the text part for facebook, somehow it is not working, tried a number of things, but just wouldn't work...

:sign0148:

Has anyone been able to get the Facebook text part to work? If, and also for other sharing programs, would it be possible to just send text messages without a picture?
 

straybullet

Member
Licensed User
Longtime User
Yes just sending text would be awesome, I have a need for text sharing only (ie custom text send to these sites)

Has anyone been able to get the Facebook text part to work? If, and also for other sharing programs, would it be possible to just send text messages without a picture?
 
Top