Intent.ACTION_GET_CONTENT用法
来源:互联网 发布:网络诈骗报警能追回吗 编辑:程序博客网 时间:2024/06/11 02:52
先对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 noFaceDetectionstartActivityForResult(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中传入的参数MediaStore.EXTRA_OUTPUT的类型是File则,action 是Uri地址,如:
Intent { act=content://media/external/images/media/1843 (has extras) }如果传入的是Uri类型,则action是file地址,如:
Intent { act=file:///mnt/sdcard/tempPhoto.jpg (has extras) }
注意:1、以上代码是在2.3.3版本完成测试的。
2、2.1版本之前 MediaStore.EXTRA_OUTPUT,该属性可以指定一个Uir,系统会将文件地址映射为该Uri地址,但在之后版本不支持该属性。
- 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 用法
- POJ 2318 TOYS (计算几何,向量积,二分查找)
- C#中两个窗体将相互跳转
- FileInputStream 之read(byte [] b)方法
- 用JQUERY处理THINKPHP构造返回的多级JSON数据
- 封装一个类搞定90%安卓客户端与服务器端交互
- Intent.ACTION_GET_CONTENT用法
- wcf 回调
- 7月8日,2012 -- 编程为主,超级玛丽很久
- 23种设计模式(9):访问者模式
- java web中表单数据传输乱码的解决方案记录
- 蓝牙协议中HCI层的研究与开发
- ⊙ 响应时间
- Oracle EBS License Price
- Tomcat源码分析(六)--日志记录器和国际化