处理方法
你可以共享下面的代码:
String shareBody = "Here is the share content body";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using)));
所以你的全部代码(图片+文本)需要变成
- private Uri imageUri;
- private Intent intent;
- imageUri = Uri.parse("android.resource://" + getPackageName()
- + "/drawable/" + "ic_launcher");
- intent = new Intent(Intent.ACTION_SEND);
- //text
- intent.putExtra(Intent.EXTRA_TEXT, "Hello");
- //image
- intent.putExtra(Intent.EXTRA_STREAM, imageUri);
- //type of things
- intent.setType("*/*");
- //sending
- startActivity(intent);
把image/*替换成 with */*
更新:
- Uri imageUri = Uri.parse("android.resource://" + getPackageName()
- + "/drawable/" + "ic_launcher");
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello");
- shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
- shareIntent.setType("image/jpeg");
- shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- startActivity(Intent.createChooser(shareIntent, "send"));
原文地址:http://www.itmmd.com/201411/214.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。
相关推荐
本文讲述了Android版Intent.ACTION_SEND分享图片和文字内容。分享给大家供大家参考,具体如下: 编辑推荐:稀土掘金,这是一个针对技术开发者的一个应用,你可以在掘金上获取最新最优质的技术干货,不仅仅是Android...
主要介绍了Android利用Intent.ACTION_SEND进行分享,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
接收系统的时间流逝的广播,屏幕开启关闭的广播,电量改变的广播。这些广播在清单文件里注册时,看不到效果。在这个例子中通过在一个服务里面用代码注册的方式,成功接收了这些广播。
移动开发Kotlin in action完整清晰版,google移动跨平台开发Flutter官方开发语言dart in action
获取系统图片的简单示例,使用Intent.ACTION_GET_CONTENT 和 MediaStore两种方式获取图片以及其真正的系统所在的位置
http://blog.csdn.net/xuie0000/article/details/50604741用例
主要介绍了Android编程实现自定义分享列表ACTION_SEND功能的方法,结合实例形式详细分析了自定义分享列表功能的步骤与具体操作技巧,需要的朋友可以参考下
在Android手机中接收android智能手表通知信息
Android自定义action与permission的方法教程 pdf
使用android.provider.MediaStore类定义的意图ACTION_IMAGE_CAPTURE。这个意图可以用于启动相机、拍摄照片并返回照片信息。 //跳转到程序相机页面 Intent intent = new Intent(android.provider.MediaStore.ACTION_...
最新android教程第三版,火热出炉,学安卓必看.
在进行Android开发的过程中,免不了,要开发TCP/UDP通讯的程序,下面这两段代码,分别介绍了TCP/UCP通过的一个实例: 代码一: private void tcpdata() { try { Socket s = new Socket("192.168.0.25", 65500); ...
JSONObject json=new JSONObject()                   //【这里在JSON中包含一个Map】                  Map map=new HashMap<...
Smart Gallery with Single and Multiple image pick action. Features luminous.ACTION_PICK for choosing single image. luminous.ACTION_MULTIPLE_PICK for choosing multiple image. Also custom Theme. - - ...
Android状态保存、用户偏好设置保存、通过universal_image_loder网络加载图片并做图片缓存处理Demo 1、将universal-image-loder...jar包放入项目的libs文件里,并引入。 2、将MyApplication.java类放入项目,具体...
android.intent.action.PACKAGE_REMOVED和android.intent.action.PACKAGE_ADDED 可以监听别的应用被安装卸载,但不能监听自己被卸载啊。 监听自己被卸载通过前辈们探索发现,只能通过监听系统卸载log如:act=...
在Android手机中接收android智能手表通知信息
《Android平板电脑应用开发入门经典》向Android新手快速介绍了如何使用Android 3开发平板应用。经验丰富的作者Wei-Meng Lee首先介绍了如何安装必要的工具并编写HelloWorld应用。接下来介绍Android平板应用的各种组件...