12

I'd like to share a photo with caption pre-filled from my app via a share intent, on facebook.

I know how to share photo or how to share text, but how do I share them together?

Example code

Intent shareCaptionIntent = new Intent(Intent.ACTION_SEND);
    shareCaptionIntent.setType("image/*");

    //set photo
    shareCaptionIntent.setData(examplePhoto);
    shareCaptionIntent.putExtra(Intent.EXTRA_STREAM, examplePhoto);

    //set caption
    shareCaptionIntent.putExtra(Intent.EXTRA_TEXT, "example caption");
    shareCaptionIntent.putExtra(Intent.EXTRA_SUBJECT, "example caption");

    startActivity(Intent.createChooser(shareCaptionIntent,getString(R.string.share)));

If a set type to image/* then a photo is uploaded without the caption prefilled. If a set it to text/plain only the caption is uploaded without the photo.....


My guess is that the issue is that the Android Facebook App doesn't look for Intent.EXTRA_TEXT when it filters an ACTION_SEND Intent with type image/* for photo uploading. So this issue could be resolved if the Android Facebook App looked for that value, and if present, inserted it as the caption of the image.

Share caption via Android Intent

Moog
  • 10,193
  • 2
  • 40
  • 66
siamii
  • 23,374
  • 28
  • 93
  • 143
  • did you figure this out? – ekawas Apr 23 '11 at 17:41
  • @ekawas I haven't. The official facebook app doesn't support text on sharing a photo. And alternative solution I found is to integrate the facebook api into your app and share the photo with caption through that, but that's a lot more complicated than intents. – siamii Apr 24 '11 at 04:38
  • Also, I'm not that keen on having a separate menu button just to share on Facebook, while other apps, such as Twitter, Gmail, Flickr do support the generic share intent for photos with caption. – siamii Sep 10 '11 at 14:16
  • Have you tried using an archive mime type, such as application/zip and put the image and text inside? I wonder how that would be handled? – FrinkTheBrave Sep 12 '11 at 20:40
  • @may i know how can i share image or text in facebook in programatically – Harsha Feb 28 '13 at 05:46
  • How is it that you set the photo with facebook, I have it working with twitter, instagram, falcon pro and everything else, but facebook won't display the image – Phil Andrews Jul 24 '13 at 09:20

2 Answers2

10

Add this line to your existing codes:

shareCaptionIntent.putExtra(Intent.EXTRA_TITLE, "my awesome caption in the EXTRA_TITLE field");

There is no clearly defined differences among EXTRA_TITLE, EXTRA_SUBJECT and EXTRA_TEXT. So there is no clear share protocol. We could always try them all. :-)

Frank Du
  • 516
  • 4
  • 12
  • Thank you! it worked! Although the definition of Intent.EXTRA_TITLE is _A CharSequence dialog title to provide to the user when used with a ACTION_CHOOSER._ And Intent.EXTRA_TEXT _A constant CharSequence that is associated with the Intent, used with ACTION_SEND to supply the literal data to be sent._ – siamii Sep 20 '11 at 07:58
  • can u give me a link or example link so i can apply in my app.. thanks – Rahul Baradia Apr 11 '12 at 10:48
  • 1
    Tech.Rahul, still need any help with this? – n00b programmer May 20 '12 at 06:00
  • This doesnt work anymore. Facebook does not allow it – Greg Ennis Jul 26 '14 at 18:35
  • Doesn't work. See https://developers.facebook.com/bugs/332619626816423/ what a shame! – j.c Jul 30 '14 at 12:01
8

This issue appear to be a long standing "feature" of the facebook app. It's handling of intents has never been in a fully functional state.

Check the links on http://forum.developers.facebook.net/viewtopic.php?id=93900

This needs to be elevated with the developers at facebook. The reliance on hiding behind the Client API rather than fixing the obvious is working against them.

Moog
  • 10,193
  • 2
  • 40
  • 66
  • I true solution would have been a reply from a facebook representative, but since the lack of that, I'll award you the bounty. – siamii Sep 17 '11 at 18:47
  • This link may clarify what's happening: https://developers.facebook.com/bugs/332619626816423/ Facebook has no ears. – j.c Jul 30 '14 at 12:00