Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share text via Intent on Facebook without using Facebook sdk

As Facebook doesn't allow sharing text via Intent unless we use Facebook sdk, I am looking for a way around to achieve this.

I can think of 3 hacks which I can use:

1) As Facebook allows image sharing, I can generate a Bitmap with sharing text drawn onto it and share the image using Intent.

2) Facebook allows sharing URLs, for which it also displays the Head of the page while sharing. I can host a dedicated page on my server and pass values as parameter in the url, and generate the Head using it.(I have no experience with php, but I guess this is possible)

3) Copy text to clipboard and notify user about this.

OR

Use combinations of all 3.

Can anyone suggest me a much better way around to share my content on Facebook without using Facebook sdk?

Thanks in advance.

like image 238
Hemanth Avatar asked Jan 05 '16 18:01

Hemanth


People also ask

What can you do with Facebook SDK?

The Facebook SDK for Android gives you access to the following features: Facebook Login — A secure and convenient way for people to log into your app or website by using their Facebook credentials. Sharing — Enable people to post to Facebook from your app. People can share, send a message, and share to stories.

How do I share intent?

For all types of sharing, create an intent and set its action to Intent. ACTION_SEND . In order to display the Android Sharesheet you need to call Intent. createChooser() , passing it your Intent object.


1 Answers

There is no way you can share Text alone in the Facebook using android shareIntent.

It is possible only through Facebook SDK using share links functions.

Facebook simply ignores the Extra Text from the intent if there is an image. You can share image, but it does not allow you to share the Text content.

Unfortunately the Facebook sharing intent can only take a single URL with prefixed http:// and no additional text message. Actually facebook strips out the text content and allows only URL/Link. It is by Design and we have no control over it.

This will work

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com"); startActivity(Intent.createChooser(sharingIntent, "Share via")); 

This will not work.

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_TEXT, "Share Text from App"); startActivity(Intent.createChooser(sharingIntent, "Share via")); 

Only approach you can share the text in the Facebook is using Facebook SDK.

Reference Links

Android share intent for facebook- share text AND link

Unable to share text with a link through Android Share Intent

Android and Facebook share intent

like image 51
Swaminathan V Avatar answered Oct 17 '22 06:10

Swaminathan V