Android 如何使用 Intent 发送文本和图像或任何对象?

标签 android image text android-intent share

我知道可以通过指定 Intent.EXTRA_TEXTACTION_SEND 共享短信。同样的方法适用于图像 - Intent.EXTRA_STREAM

但是我怎样才能将文本和图像添加到同一个 Intent 中呢?

最佳答案

您可以通过 intent 发送文本和图像

如果您使用 Intent ACTION 发送,那么,

只发送一个数据,无论是文本还是流使用,

Intent intent = new Intent(Intent.ACTION_SEND);

一次发送多个数据,

Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);


通常从一个特定的 Activity 发送到任何另一个特定的 Activity,

发送

Bitmap bmp = "Your Bitmap";
String txt = "Text";
Intent intent = new Intent(ActivityName.this,SecondFile.class);
intent.putExtra("Text",txt);
intent.putExtra("Img",bmp);
startActivity(intent);

接收

Intent intent = this.getIntent();
String txt = intent.getStringExtra("Text");
Bitmap bmp = intent.getParcelableExtra("Img");

关于Android 如何使用 Intent 发送文本和图像或任何对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7807465/

相关文章:

android - 用于调试的 HTC Wildfire 插件在 UBUNTU 中不起作用

android - 如何将图像从设备上传到服务器以及如何在进度条上显示已上传多少数据?

c - 在 C 中读取具有不同扩展名的 .txt 文件

html - HTML 文本周围的颜色

java - java中使用java.awt.Graphics2D的变形图像

javascript - 如何获得 SVG 文本元素的紧密边界框

java - 一键执行 2 种不同操作

android - api19上的android.content.res.Resources $ NotFoundException

android - 当设备语言更改时,TextView 显示不在 strings.xml 中的字符串

iPhone 存储远程服务器图像