开发者

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

开发者 https://www.devze.com 2023-02-14 23:59 出处:网络
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?

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 filter开发者_如何学Gos 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.

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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消