Intent.ACTION_GET_CONTENT用法
来源:互联网 发布:修复php intl.dll软件 编辑:程序博客网 时间:2024/06/04 20:41
先对ACTION_GET_CONTENT做一下说明:
ACTION_GET_CONTENT:允许用户选择特殊种类的数据,并返回(特殊种类的数据:照一张相片或录一段音)
剪切图片
- Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
- intent.setType("image/*");
- intent.putExtra("crop", "true");
- intent.putExtra("aspectX", aspectX);
- intent.putExtra("aspectY", aspectY);
- intent.putExtra("outputX", outputX);
- intent.putExtra("outputY", outputY);
- intent.putExtra("scale", scale);
- // intent.putExtra("return-data", true);
- intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile()));
- intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
- intent.putExtra("noFaceDetection",!faceDetection); // lol, negative boolean noFaceDetection
- startActivityForResult(intent, PHOTO_PICKED);
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- String action = data.getAction();
- //如果 intent.putExtra("return-data", true);则可以得到返回的Bitmap数据
- final Bundle extras = data.getExtras();
- Bitmap bitmap = extras.getParcelable("data");
- }
- Intent { act=content://media/external/images/media/1843 (has extras) }
- Intent { act=file:///mnt/sdcard/tempPhoto.jpg (has extras) }
注意:1、以上代码是在2.3.3版本完成测试的。
2、2.1版本之前 MediaStore.EXTRA_OUTPUT,该属性可以指定一个Uir,系统会将文件地址映射为该Uri地址,但在之后版本不支持该属性。
0 0
- Intent.ACTION_GET_CONTENT用法
- Intent.ACTION_GET_CONTENT用法
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT
- android之Itent.ACTION_PICK Intent.ACTION_GET_CONTENT妙用
- Intent.ACTION_GET_CONTENT和Intent.ACTION_PICK的使用区别
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(一)
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(二)
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(三)
- Android 巧用Itent.ACTION_PICK和Intent.ACTION_GET_CONTENT(三)
- Intent用法
- Intent用法
- intent 用法
- liunx c语言制作 微型web服务器 300行代码
- 动态规划的基本概念和最优化原理
- CAS (5) —— Nginx代理模式下浏览器访问CAS服务器配置详解
- 打包时出现No matching provisioning profile found错误的解决方法
- 初步研究3D Touch
- Intent.ACTION_GET_CONTENT用法
- SQLite3环境配置以及SQLite Expert Professional 3安装
- 读《疯狂Java讲义》笔记总结一
- MFC序列化值得注意的问题
- C语言之预处理
- IntelliJ Idea :Cannot load project: java.lang.RuntimeException: java.io.IOException: java.lang.Asser
- 伪类link,visited,focus,hover,active详解
- 自定义View的状态 (Checkable接口引发的联想)
- 文章标题