Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Share Text on Facebook from Android App via ACTION_SEND

I have an Android app and it supports sending text via other apps. It therefore uses the ACTION_SEND intent and the EXTRA_TEXT field. The chooser presents me with all apps that can handle such an intent. Those are Twitter, Email, ... and Facebook. But when I select Facebook it opens the browser and goes to the following page:

http://m.facebook.com/sharer.php?u=mytext

It shows my text and the submit button. But when I press the submit button nothing happens. The page just loads again. I think maybe it is only possible to send URLs via the Facebook App. Could that be?

Did anyone manage to send text via ACTION_SEND through the Facebook Android app?

like image 401
Goddchen Avatar asked Aug 18 '10 18:08

Goddchen


2 Answers

To make the Share work with the facebook app, you only need to have suply at least one link:

Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, "Wonderful search engine http://www.google.fr/"); startActivity(Intent.createChooser(intent, "Share with")); 

This will show the correct sharing window but when you click on share, nothing happends (I also tried with the official Twitter App, it does not work).

The only way I found to make the Facebook app sharing work is to share only a link with no text:

Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, "http://www.google.fr/"); startActivity(Intent.createChooser(intent, "Share with")); 

It will show the following window and the Share button will work:

facebook share

Apparently it automatically takes an image and text from the link to populate the share.

If you want to share only text, you will have to use the facebook api: https://github.com/facebook/facebook-android-sdk

like image 54
ol_v_er Avatar answered Oct 07 '22 03:10

ol_v_er


06/2013 :

  • This is a bug from Facebook, not your code
  • Facebook will NOT fix this bug, they say it is "by design" that they broke the Android share system : https://developers.facebook.com/bugs/332619626816423
  • use the SDK or share only URL.
  • Tips: you could cheat a little using the web page title as text for the post.
like image 21
Loda Avatar answered Oct 07 '22 02:10

Loda