ACTION_SEND在同一个意图同时发送图片和文字 [英] ACTION_SEND sending both an Image and Text in the same Intent

查看:274
本文介绍了ACTION_SEND在同一个意图同时发送图片和文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想这样做是这样的:

So I would like to do something like:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(myMessageAsImage));
intent.putExtra(Intent.EXTRA_TEXT, "My Message");
intent.setType("text/plain"); // or intent.setType("image/<imageType>");

不过,对于ACTION_SEND的文件似乎并没有使这似乎成为可能。有没有办法在商定做到这一点?

However the documentation for ACTION_SEND doesn't seem to make this seem possible. Is there an agreed upon way to do this?

推荐答案

我不知道你的共同方式的意思,但我认为你应该类型设置为 intent.setType(图像/ *);

I don't know what you mean by 'common way' but I think you should set the type to intent.setType("image/*");.

编辑:

您如何意图发送数据取决于过滤特定的应用程序操作的可用性。用于处理ACTION_SEND不得办理ACTION_SEND_MULTIPLE应用。在HTC画廊点击分享产生的用于处理图像,单个或多个应用程序的列表。如果您选择邮件,那么你可以选择多个图像。但是如果你选择Facebook或窥视,那么你只能选择一个图像。这是我简单的解决方案,如果你想要做的HTC库相反,那就是:用户选择图像(S)第一则显示他根据他多少选择的所有兼容的应用程序。

How you send data with intent depends on the availability of apps that filter your particular action. Apps that handle ACTION_SEND may not handle ACTION_SEND_MULTIPLE. Clicking Share on HTC Gallery produces a list of applications that handle image, single or multiple. If you choose Mail then you can select multiple images. But if you choose Facebook or Peep then you can only select one image. This is my simple solution if you want to do the reverse of HTC Gallery, that is: user chooses image(s) first then you show him all compatible apps based on how many he selected.

// assuming uris is a list of Uri
Intent intent = null;
if (uris.size > 1){
intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
} else if (uris.size() == 1) {
intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, uris.get(0));}
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TEXT, "Some message");
startActivity(Intent.createChooser(intent,"compatible apps:"));

这篇关于ACTION_SEND在同一个意图同时发送图片和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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