我想通过共享 Intent 在 Facebook 上分享一张带有从我的应用程序预填充的标题的照片。
我知道如何分享照片或如何分享文字,但我如何将它们一起分享?
示例代码
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
,则仅上传标题而不上传照片......
我的猜测是,问题在于 Android Facebook 应用程序在过滤类型为 image/的
用于上传照片。 因此,如果 Android Facebook 应用程序查找该值,则可以解决此问题,如果存在,则将其作为图片的标题插入。 ACTION_SEND
Intent 时不会查找 Intent.EXTRA_TEXT
*
最佳答案
将此行添加到您现有的代码中:
shareCaptionIntent.putExtra(Intent.EXTRA_TITLE, "my awesome caption in the EXTRA_TITLE field");
EXTRA_TITLE、EXTRA_SUBJECT 和 EXTRA_TEXT 之间没有明确定义的区别。所以没有明确的共享协议(protocol)。我们总是可以尝试所有这些。 :-)
关于android - 如何通过 Android 在 Facebook 上分享带有 CAPTION 的照片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5214764/