在 Twitter 上使用 SHARE INTENT 共享组合文本和图像时出现问题 [英] Problems sharing combined text and image with SHARE INTENT on Twitter

查看:16
本文介绍了在 Twitter 上使用 SHARE INTENT 共享组合文本和图像时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让用户可以在 Twitter 和 Facebook 上分享图片和文字.

I want to give the user the possibility to share a Image and a Text with Twitter and Facebook.

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

Actually my code can launch Android's share intent and if the user selects Facebook, all works fine, the Image is attached and the text is shown on the body of the new status.

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

But something is wrong with Twitter, if i only put a Image all works fine, the image is detected by twitter and automatically uploaded to twipic, then twitter posts the link of the image on the tweet. But if i put a image and a text, then, twitter doesn't detect the image and it only puts the text on the tweet, the image is ignored. What is wrong?

这是我的代码:

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"));

推荐答案

也为文本指定 MIME 类型."text/plain" 是文本数据 MIME 的类型.尝试使用 "*/*" 作为 MIME,这样您就可以发送任何通用数据类型.

Specify MIME type also for the text. "text/plain" is the type of text data MIME. Try using "*/*" as MIME, so you can send any generic data type.

还可以尝试将 ACTION_SEND 更改为 ACTION_SEND_MULTIPLE,专门用于传送多个数据.

Also try changing ACTION_SEND to ACTION_SEND_MULTIPLE which specialized for delivering multiple data.

有关 ACTION_SEND_MULTPLE 和处理 MIME 类型的更多信息:

More info about ACTION_SEND_MULTPLE and handling MIME types:

http://developer.android.com/reference/android/content/Intent.html

这篇关于在 Twitter 上使用 SHARE INTENT 共享组合文本和图像时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆