我知道可以通过指定 Intent.EXTRA_TEXT
与 ACTION_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/