问题描述
我想通过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 App不会在 Intent.EXTRA_TEXT
中查找<$ c c $ c> ACTION_SEND 用于照片上传的类型为 image / *
的意图。 所以如果Android的Facebook应用程序查找该值,那么这个问题可以解决,如果存在的话,将其插入到图片的标题中。
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. :-)
这篇关于如何通过Android分享意图在Facebook上与CAPTION分享照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!