android开发使用ACTION_SEND完美共享图片和文本实例

我想使用 ACTION_SEND 共享图片+文字,我运行了下面的代码,暂时只能共享图片,无法共享文字,我如何才能共享?

 代码如下 复制代码
private Uri imageUri;
       private Intent intent;
 
        imageUri = Uri.parse("android.resource://" + getPackageName()
                + "/drawable/" + "ic_launcher");
        intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, "Hello");
        intent.putExtra(Intent.EXTRA_STREAM, imageUri);
        intent.setType("image/*");
        startActivity(intent);

//如何才能共享图片?
处理方法

你可以共享下面的代码:

 代码如下 复制代码
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);
时间: 2024-07-31 09:11:43

android开发使用ACTION_SEND完美共享图片和文本实例的相关文章

Android开发中用相机拍照后图片裁剪的实例及源码

其实Android提供Intent让我们打开系统的相机,但是系统相机跟自己app风格不搭,而且用起来体验不好.所以我使用了SDK提供的camera API自定义了一个相机,并且在相机界面上面添加了参考线,有助于用户将题目拍正,提高ocr的识别率. 1.绘制参考线的代码 public class ReferenceLine extends View {     private Paint mLinePaint;     public ReferenceLine(Context context) {

Android开发之使用ViewPager实现图片左右滑动切换效果_Android

Android中图片的左右切换随处可见,今天我也试着查阅资料试着做了一下,挺简单的一个小Demo,却也发现了一些问题,话不多说,上代码~: 使用了3个xml文件作为ViewPager的滑动page,布局都是相同的,如下只展示其中之一: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/

Android开发之使用GridView展示图片的方法_Android

本文实例讲述了Android使用GridView展示图片的方法.分享给大家供大家参考,具体如下: 今天说说GridView的使用. 所谓GvidView翻译过来就是网格布局:是一个ViewGroup以网格显示它的子视图(view)元素,即二维的.可滚动的网格.网格元素通过ListAdapter自动插入到网格. 这个GridView用处特别多,我这里是用来展示广告的.2*3的广告位置. 废话少说先看个效果图,有图就可以说个XX,对吧,大家都懂的. 大家可以看到搜索下面的那6个块,效果布局还行吧,哈

Android开发之使用ViewPager实现图片左右滑动切换效果

Android中图片的左右切换随处可见,今天我也试着查阅资料试着做了一下,挺简单的一个小Demo,却也发现了一些问题,话不多说,上代码~: 使用了3个xml文件作为ViewPager的滑动page,布局都是相同的,如下只展示其中之一: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/

Android开发Popwindow仿微信右上角下拉菜单实例代码_Android

先给大家看下效果图: MenuPopwindow: package com.cloudeye.android.cloudeye.view; import android.app.Activity; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import an

Android开发Popwindow仿微信右上角下拉菜单实例代码

先给大家看下效果图: MenuPopwindow: package com.cloudeye.android.cloudeye.view; import android.app.Activity; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import an

Android开发实现的Intent跳转工具类实例

本文实例讲述了Android开发实现的Intent跳转工具类.分享给大家供大家参考,具体如下: 一.概述 Intent的中文意思是"意图,意向",在Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作.动作涉及数据.附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 Intent传递给调用的组件,并完成组件的调用.Intent不仅可用于应用程序之间,也可用于应用程序内部的Activity/Service之

Android开发实现自定义新闻加载页面功能实例

本文实例讲述了Android开发实现自定义新闻加载页面功能.分享给大家供大家参考,具体如下: 一.概述: 1.效果演示: 2.说明:在新闻页面刚加载的时候,一般会出现五种状态 未知状态(STATE_UNKNOW).空状态(STATE_EMPTY).加载中(STATE_LOADING).错误(STATE_ERROT).成功(STATE_SUCCESS) 因为每个Detail页面都会出现,所以我们可以把他们封装成一个LoadPage的自定义view,可以复用 二.实现: 1.首先的定义三个布局,为什

Android Tween动画之RotateAnimation实现图片不停旋转效果实例介绍_Android

主要介绍Android中如何使用rotate实现图片不停旋转的效果.Android 平台提供了两类动画,一类是 Tween 动画,即通过对场景里的对象不断做图像变换(平移.缩放.旋转)产生动画效果:第二类是 Frame 动画,即顺序播放事先做好的图像,跟电影类似.本文分析 Tween动画的rotate实现旋转效果. 在新浪微博客户端中各个操作进行中时activity的右上角都会有个不停旋转的图标,类似刷新的效果,给用户以操作中的提示.这种非模态的提示方式推荐使用,那么下面就分享下如何实现这种效果