Android的如何发送文本和图像或使用意图的任何对象? [英] Android How to send text and images or any object using intent?

查看:140
本文介绍了Android的如何发送文本和图像或使用意图的任何对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是可以通过指定 Intent.EXTRA_TEXT 来分享 ACTION_SEND 短信。同样的方法适用于图像 - Intent.EXTRA_STREAM

I know it's possible to share a text message with ACTION_SEND by specifying Intent.EXTRA_TEXT. Same approach works for images - Intent.EXTRA_STREAM.

但我怎么能文本和图像相同的意图补充的吗?

But how can I add both text and image to the same intent?

推荐答案

您可以通过发送意图的文字和图片一样

you can send text and image via intent like

如果您要发送的使用意图操作,然后,

If you are sending using Intent ACTION then,

要只发送一个数据文本或流的使用,

To send only one data either text or stream use,

意向意图=新意图(Intent.ACTION_SEND);

要发送一个以上的数据在使用时,

To send more then one data at a time use,

意向意图=新意图(Intent.ACTION_SEND_MULTIPLE);

通常送从一个特定的活动,以任何另一个特定活动,

Normally to send from one specific Activity to any another specific 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的如何发送文本和图像或使用意图的任何对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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