Android中通过Intent 调用图片、视频、音频、录音、拍照
来源:互联网 发布:oracle和mysql学哪个 编辑:程序博客网 时间:2024/06/05 14:15
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");
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
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用系统的图片、视频、音频、录音、拍照
- Android中通过Intent 调用系统的图片、视频、音频、录音、拍照
- (转)Android中通过Intent 调用图片、视频、音频、录音、拍照
- Android中通过Intent 调用图片、视频、音频、录音、拍照的代码模板
- android通过Intent调用手机图片,音频,视频录音拍照等代码
- android通过Intent调用手机图片,音频,视频录音拍照等代码
- 在Android中调用图片、视频、音频、录音、拍照
- 在Android中调用图片、视频、音频、录音、拍照
- 在Android中调用图片、视频、音频、录音、拍照
- android调用系统的图片,视频,音频,录音,拍照
- 在Android 中调用选择图片、视频、添加音频、录音、拍摄视频、拍照等其他的功能
- 在Android 中调用选择图片、视频、添加音频、录音、拍摄视频、拍照等其他的功能
- 这些年的项目管理心得
- 链栈(简单的入栈出栈)
- js Function.call
- 每天学点linux命令(5)
- Liunx 运行用 Intel MKL 库文件的程序出错 “error while loading shared libraries libmkl_intel.so” 解决办法
- Android中通过Intent 调用图片、视频、音频、录音、拍照
- 安卓巴士Android开发神贴整理
- 第十六周实验报告任务3--电子词典
- 红帽6.2 DOS无盘 NetWare 制作
- 设计模式
- html
- C中的volatile用法
- TMT行业入门级的书目
- PIC16F877A输入检测问题