1. android中的一个隐藏的类:ContentType,其中定义了android支持的mimetype类型   类的路径: com.google.android.mms.ContentType
2. Action为Intent.ACTION_GET_CONTENT的Intent可以设置许多参数,如:   intent.putExtra("crop", "true");
intent.putExtra("outputX", appsWallpaperWidth);
intent.putExtra("outputY", apps_wallpaper_height);
intent.putExtra("aspectX", appsWallpaperWidth);
intent.putExtra("aspectY", apps_wallpaper_height);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra("output", appsWallpaperPath);
intent.putExtra("outputFormat", "JPEG"); 3. 使用startActivityForResult方法启动Intent对应的Activity,可以在原Activity的回调方法onActivityResult方法中拿到返回的数据.返回的数据放在第三个参数data(Intnet类型)中.   使用getData返回一个Uri,再使用context.getContentResolver().openInputStream(uri);可以拿到一个输入流.    //选择图片 requestCode 返回的标识 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //"android.intent.action.GET_CONTENT" intent.setType(contentType); //查看类型 String IMAGE_UNSPECIFIED = "image/*"; Intent wrapperIntent = Intent.createChooser(intent, null); ((Activity) context).startActivityForResult(wrapperIntent, requestCode); //添加音频 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*"; Intent wrapperIntent = Intent.createChooser(intent, null); ((Activity) context).startActivityForResult(wrapperIntent, requestCode); //拍摄视频 int durationLimit = getVideoCaptureDurationLimit(); //SystemProperties.getInt("ro.media.enc.lprof.duration", 60); Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, sizeLimit); intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, durationLimit); startActivityForResult(intent, REQUEST_CODE_TAKE_VIDEO); //视频 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(contentType); //String VIDEO_UNSPECIFIED = "video/*"; Intent wrapperIntent = Intent.createChooser(intent, null); ((Activity) context).startActivityForResult(wrapperIntent, requestCode); //录音 Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType(ContentType.AUDIO_AMR); //String AUDIO_AMR = "audio/amr"; intent.setClassName("com.android.soundrecorder", "com.android.soundrecorder.SoundRecorder"); ((Activity) context).startActivityForResult(intent, requestCode); //拍照 REQUEST_CODE_TAKE_PICTURE 为返回的标识 Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //"android.media.action.IMAGE_CAPTURE"; intent.putExtra(MediaStore.EXTRA_OUTPUT, Mms.ScrapSpace.CONTENT_URI); // output,Uri.parse("content://mms/scrapSpace"); startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
参考: http://www.cnblogs.com/top5/archive/2012/05/04/2482235.html


更多相关文章

  1. 解决EditText不显示光标的三种方法(总结)
  2. JS判断Android、iOS或浏览器的多种方法(四种方法)
  3. Android View onMeasure 方法
  4. Android Studio 3.0以后打包修改文件名方法
  5. 【Android】android开发过程遇到的问题以及解决方法总结
  6. android图片压缩方法
  7. android ndk 入门2 - 基本方法实现
  8. Android中获得上下文的静态方法

随机推荐

  1. Android(安卓)Studio编译运行project报错
  2. [Android官方Demo系列] PageTransformer
  3. Android(安卓)的R类
  4. android 动态布局
  5. Android(安卓)java List 转Json格式
  6. Android中如何实现图像的闪动
  7. Android(安卓)2.3 Rotation and Orientat
  8. android ListView监听滚动条滚动到底部时
  9. 开源android项目分享
  10. android百度地图半径画圆