问题分享在Twitter分享意图合并文本和图像

编程入门 行业动态 更新时间:2024-10-10 12:24:32
本文介绍了问题分享在Twitter分享意图合并文本和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想给用户一个共享图像和Twitter和Facebook上的文本的可能性。

其实我的code能推出Android的市场份额意图,如果用户选择的Facebook,一切工作正常,图像连接和文本显示上的新地位的机构。

但有些事情是错的微博,如果我只是把一个图像的所有工作正常,图像是由Twitter的检测,并自动上传到twipic,那么Twitter的职位图像上鸣叫的链接。但是,如果我把图像和文字,然后,微博不检测的图像,它只是把文字的鸣叫,图像将被忽略。什么是错的?

这是我的code:

意图sharingIntent =新的意图(Intent.ACTION_SEND); 乌里screenshotUri = Uri.parse(文件:///sdcard/image.jpg); sharingIntent.setType(图像/ *); sharingIntent.putExtra(Intent.EXTRA_TEXT的新地位正文文本); sharingIntent.putExtra(Intent.EXTRA_STREAM,screenshotUri); startActivity(Intent.createChooser(sharingIntent,分享图像使用));

解决方案

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

也可以尝试改变 ACTION_SEND 到 ACTION_SEND_MULTIPLE 它专门用于传送多个数据。

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

developer.android/reference/android/content/Intent.html

I want to give the user the possibility to share a Image and a Text with Twitter and 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.

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?

this is my code:

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

解决方案

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.

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

More info about ACTION_SEND_MULTPLE and handling MIME types:

developer.android/reference/android/content/Intent.html

更多推荐

问题分享在Twitter分享意图合并文本和图像

本文发布于:2023-11-28 10:48:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642091.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:意图   图像   Twitter   文本和

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!