Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share photo with CAPTION via Android share intent on Facebook?

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

like image 252
siamii Avatar asked Mar 07 '11 01:03

siamii


2 Answers

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. :-)

like image 199
Frank Du Avatar answered Oct 02 '22 04:10

Frank Du


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.

like image 44
Moog Avatar answered Oct 02 '22 03:10

Moog