示意代码:

/** * 调用系统的分享功能 * Created by admin on 15-4-13. */public class ShareActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.share_layout);    }    //分享文字    public void shareText(View view) {        Intent shareIntent = new Intent();        shareIntent.setAction(Intent.ACTION_SEND);        shareIntent.putExtra(Intent.EXTRA_TEXT, "This is my Share text.");        shareIntent.setType("text/plain");        //设置分享列表的标题,并且每次都显示分享列表        startActivity(Intent.createChooser(shareIntent, "分享到"));    }    //分享单张图片    public void shareSingleImage(View view) {        String imagePath = Environment.getExternalStorageDirectory() + File.separator + "test.jpg";        //由文件得到uri        Uri imageUri = Uri.fromFile(new File(imagePath));        Log.d("share", "uri:" + imageUri);  //输出:file:///storage/emulated/0/test.jpg        Intent shareIntent = new Intent();        shareIntent.setAction(Intent.ACTION_SEND);        shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);        shareIntent.setType("image/*");        startActivity(Intent.createChooser(shareIntent, "分享到"));    }    //分享多张图片    public void shareMultipleImage(View view) {        ArrayList<Uri> uriList = new ArrayList<>();        String path = Environment.getExternalStorageDirectory() + File.separator;        uriList.add(Uri.fromFile(new File(path+"australia_1.jpg")));        uriList.add(Uri.fromFile(new File(path+"australia_2.jpg")));        uriList.add(Uri.fromFile(new File(path+"australia_3.jpg")));        Intent shareIntent = new Intent();        shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);        shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);        shareIntent.setType("image/*");        startActivity(Intent.createChooser(shareIntent, "分享到"));    }}

页面效果:


更多相关文章

  1. android 图片灰度处理的处理
  2. android 通过滚动条改变图片显示
  3. Android(安卓)WebView 图片自适应屏幕宽度
  4. 轮播网络图片加载适配
  5. android 图片与byte数组间的转换
  6. Android(安卓)显示网页图片
  7. Android中Adapter接口及其实现类详解
  8. android最近任务列表,删除某个应用操作
  9. android 图片点击一下就放大到全屏,再点一下就回到原界面

随机推荐

  1. 中断时间序列分析ITSA是什么? 很流行的政
  2. 趁火打劫!印度APT组织对我国医疗机构发起
  3. 用PowerShell通过Posh-SSH免密码自动登录
  4. 倡议: 你来推荐文献, 我来帮你解读, 让计
  5. 自动驾驶思考:硬件篇
  6. 推荐系统:石器与青铜时代
  7. 回放:如何构建高效能的地图定位系统
  8. 自动驾驶思考:基础架构篇
  9. 闭包函数及其应用
  10. php实现多文件上传和mvc基础