Sharing images and text with Facebook on Android

Christopher Perry picture Christopher Perry · Jan 9, 2013 · Viewed 13.2k times · Source

Facebook, why you no take images and text in share Intent?

enter image description here

I'm trying to use the standard Android share Intent to share an image, and some text. My share Intent is set up right, I've got the image in there, and I've done my end of the deal. My code, let me show you it:

public void doShare() {
    File image = getShareFile();
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("*/*");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, resultObject.getShareSubject());
    shareIntent.putExtra(Intent.EXTRA_TEXT, resultObject.getShareText());
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
    shareActionProvider.setShareIntent(shareIntent);
}

Facebook shows up in the list of apps that will handle my Intent, but it lies!!! When clicking on Facebook to actual do a share it says:

Please attach only photos or a single video.

Why Facebook, why? Why do you show up as an app that can handle my Intent, then make me look stupid to my users by not handling the Intent? You promised Facebook.

I've seen many many threads on this all over this site, and the web. Has anyone gotten this to work without having to use their API?

Answer

Simon picture Simon · Feb 22, 2013

Why? Because they are Facebook and can permit to themselves such bugs. So, they expect only images upon type is "image/". If the type is "text/plain"-then a URL should be contained in the message. Don't use .setType("/*"); Otherwise use their SDK. But in this case you'll sacrifice simplicity and flexibility of your application.