gpt4 book ai didi

android - 在 Twitter 上使用 SHARE INTENT 共享组合文本和图像时出现问题

转载 作者:IT老高 更新时间:2023-10-28 22:25:40 26 4
gpt4 key购买 nike

我想让用户能够与 Twitter 和 Facebook 共享图像和文本。

实际上我的代码可以启动 Android 的分享 Intent ,如果用户选择 Facebook,一切正常,图片已附加,文本显示在新状态的正文上。

但是 Twitter 出了点问题,如果我只放一张图片一切正常,图片会被 twitter 检测到并自动上传到 twipic,然后 twitter 会在推文上发布图片的链接。但是,如果我放了一个图像和一个文本,那么,twitter 不会检测到图像,它只会将文本放在推文上,图像会被忽略。怎么了?

这是我的代码:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file:///sdcard/image.jpg");
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));

最佳答案

您仍然可以尝试使用 ACTION_SEND,而无需使用 ACTION_SEND_MULTIPLE

ACTION_SEND_MULTIPLE 导致强制关闭,当我尝试创建新的 Intent 以共享到 Gmail、G+ 等时。

这对我来说很完美:

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
Uri uri = Uri.parse("file:///sdcard/image.jpg");
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
return shareIntent;

关于android - 在 Twitter 上使用 SHARE INTENT 共享组合文本和图像时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8296605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com