如何在 Facebook 上通过 Android 分享意图与 CAPTION 分享照片? [英] How to share photo with CAPTION via Android share intent on Facebook?
问题描述
我想通过分享意图在 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?
示例代码
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)));
如果将类型设置为 image/*
则上传的照片没有预填充标题.如果将其设置为 text/plain
,则仅上传标题而不上传照片.....
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.....
我的猜测是,问题在于 Android Facebook 应用在过滤 ACTION_SEND
类型为 image/的 Intent 时不会查找
用于照片上传.因此,如果 Android Facebook 应用程序查找该值,并且将其作为图像标题插入(如果存在),则可以解决此问题. Intent.EXTRA_TEXT
*
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.
推荐答案
将此行添加到您现有的代码中:
Add this line to your existing codes:
shareCaptionIntent.putExtra(Intent.EXTRA_TITLE, "my awesome caption in the EXTRA_TITLE field");
EXTRA_TITLE、EXTRA_SUBJECT 和 EXTRA_TEXT 之间没有明确定义的区别.所以没有明确的共享协议.我们总是可以尝试所有这些.:-)
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. :-)
这篇关于如何在 Facebook 上通过 Android 分享意图与 CAPTION 分享照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!