android - 如何通过 Android 在 Facebook 上分享带有 CAPTION 的照片?

标签 android facebook

我想通过共享 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/的 ACTION_SEND Intent 时不会查找 Intent.EXTRA_TEXT * 用于上传照片。 因此,如果 Android Facebook 应用程序查找该值,则可以解决此问题,如果存在,则将其作为图片的标题插入。

Share caption via Android Intent

最佳答案

将此行添加到您现有的代码中:

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/

相关文章:

java - Android NDK 中的 JNI 清理和守护线程

facebook - 图形 API 与 FQL 哪个更快?

flutter - 如何从 Flutter 中的 Facebook 广告获取 Facebook 安装推荐

java - Scheduler.Worker 线程上抛出异常。添加 `onError`处理

android - 添加许多模块时,区域设置的更改确实有效

android - 拦截数据库错误 "file is encrypted or is not a database"

c#-4.0 - Facebook iframe 应用程序问题

android - Google 登录始终返回 false

Facebook Graph API - 来自事件的大图像?

ios - 图形 API : how to search for friends using a keyword