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. android 关于tts的一些参数
  2. android中SharedPreferences和PreferenceActivity的存取数据
  3. android中Handler的源码分析
  4. JS判断Android、iOS或浏览器的多种方法(四种方法)
  5. android 存储联系人(save contact) 总结
  6. Android自动横屏注意事项
  7. Android的快速开发框架afinal
  8. Android第一周
  9. Android(安卓)中文 API (29) —— CompoundButton

随机推荐

  1. 【Android-FaceBook】facebook Android配
  2. android开发给linearlayout设置边框
  3. Android(安卓)APPT2 报异常处理
  4. Android中的网络编程系列(一):URLConnect
  5. Android(安卓)Studio中如何新建assets文
  6. Android(安卓)SDK Manager 代理服务器设
  7. Android遇到的异常及解决方法
  8. 描述清点击 Android(安卓)Studio 的 buil
  9. Android(安卓)Binder机制学习总结(三)-Se
  10. ViewPager实现无限循环切换和手势滑动效