【发布时间】:2011-12-10 02:01:19
【问题描述】:
我知道可以通过指定Intent.EXTRA_TEXT 与ACTION_SEND 共享短信。同样的方法适用于图像 - Intent.EXTRA_STREAM。
但是如何将文本和图像添加到同一个意图中?
【问题讨论】:
-
问题,内容提供商不能做到这一点吗?
标签: android image text android-intent share
我知道可以通过指定Intent.EXTRA_TEXT 与ACTION_SEND 共享短信。同样的方法适用于图像 - Intent.EXTRA_STREAM。
但是如何将文本和图像添加到同一个意图中?
【问题讨论】:
标签: android image text android-intent share
您可以通过 Intent 发送文本和图像
如果您使用 Intent ACTION 发送,那么,
使用文本或流仅发送一个数据,
Intent intent = new Intent(Intent.ACTION_SEND);
要一次发送多个数据,
Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
通常从一个特定活动发送到任何另一个特定活动,
发送
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");
【讨论】:
您可以向同一 Intent 添加任意数量的附加内容:
intent.putExtra(Intent.EXTRA_STREAM,imgUri);
intent.putExtra(Intent.EXTRA_TEXT,text);
希望我没有弄错你的问题。
【讨论】: