很多App都有这样一个分享图片的功能,图片的来源要么是直接从摄像头获取,要么是从相册里面选择,一个很简便实现这种功能的的方式是通过Intent提供的createChooser方法,ok,here we go,let's see the code:
Intent takePicIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);Intent pickPicIntent = new Intent(Intent.ACTION_GET_CONTENT);pickPicIntent.setType("image/*");Intent chooserIntent = Intent.createChooser(takePicIntent, "Choose intent");chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickPicIntent});startActivityForResult(chooserIntent, REQUEST_CODE);
启动的多余的Intent用数组的形式组合起来,传递给createChooser.

更多相关文章

  1. Adapter 优化图片复用,导致界面图片出现闪烁效果
  2. Android(安卓)资源
  3. ImageView设置图片的几种方式
  4. Android(安卓)CoordinatorLayout使用 标题由图片变纯色
  5. Android(安卓)ScaleType 详解,使用
  6. Android中如何获取Bitmap(总结)
  7. 通过WifiManager可以实现对wifi进行操作,实现wifi自动连接等一些
  8. Android(安卓)LsitView的实现
  9. Android——拍照、剪切、得到图片/从相册中选择照片(api19以上和

随机推荐

  1. 捕获TextView超链接
  2. android 自动弹起键盘
  3. Android(安卓)PreferenceActivity简介
  4. 恢复出厂设置的两种方法,亲测可行
  5. 【Android】Android6.0+ 动态申请权限
  6. Android(安卓)Socket通信
  7. Android(安卓)通过网页打开自己的APP(sch
  8. Android本地存储和SharedPreferences
  9. Android学习系列Toolbar,AppBarLayout,Coor
  10. php的初步认识