Android--Miui6.0裁剪图片的时候返回为空的解决
来源:互联网 发布:逆袭网络剧 百度云 编辑:程序博客网 时间:2024/06/05 09:59
声明:本博客承接上文: Android–利用相机或相册截取用户头像(解决了miui无法截取,以及部分机型拍照无返回Uri)
,上一篇博客中解决了小米手机miui系统在拍照后没有返回的情况,而且截取图片的功能在6.0以下是好的,但是更新到安卓6.0后出现了一些问题,本文中解决截取功能在miui + 安卓6.0 中利用系统内部API实现。
截取功能使用的代码为下:
private void reSizeImage(Uri uri) {//重新剪裁图片的大小 //保证输出的图片文件是一个唯一的空的图片文件。 File outputImage = new File(Environment.getExternalStorageDirectory(), "crop.jpg"); try { if(outputImage.exists()) { outputImage.delete(); } outputImage.createNewFile(); } catch (Exception e) { e.printStackTrace(); } userImageUri = Uri.fromFile(outputImage); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image"); intent.setDataAndType(uri, "image/*"); // 下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪 intent.putExtra("crop", true); intent.putExtra("scale", true); intent.putExtra("scaleUpIfNeeded", true);// 去黑边 // aspectX aspectY 是宽高的比例 intent.putExtra("aspectX", 1);//输出是X方向的比例 intent.putExtra("aspectY", 1); // outputX outputY 是裁剪图片宽高,切忌不要再改动下列数字,会卡死 intent.putExtra("outputX", 500);//输出X方向的像素 intent.putExtra("outputY", 500); intent.putExtra("noFaceDetection", true); intent.putExtra("return-data", false);//设置为不返回数据 /** * 此方法返回的图片只能是小图片(测试为高宽160px的图片) * 故将图片保存在Uri中,调用时将Uri转换为Bitmap,此方法还可解决miui系统不能return data的问题 */// intent.putExtra("return-data", true);// intent.putExtra("output", Uri.fromFile(new File("/mnt/sdcard/temp")));//保存路径// userImageUri = Uri.parse("file:///"+ Environment.getExternalStorageDirectory().getPath() + "/" + "small.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, userImageUri);// intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); Log.d(TAG, "reSizeImage() called with: " + "uri = [" + userImageUri + "]"); startActivityForResult(intent, RESIZE_REQUEST_CODE); }
0 0
- Android--Miui6.0裁剪图片的时候返回为空的解决
- android 网络请求图片,返回值为空的解决办法
- 解决Hibernate查找视图有一个空值的时候返回的对象为null的问题
- android图片的裁剪
- android图片的裁剪
- Android图片的裁剪
- Android图片的裁剪
- 返回值为结构体,返回值可能为空时候的处理情况
- 调用Android相机裁剪图片太大不能返回的问题解决
- Android 压缩网络上的图片BitmapFactory.decodeStream()返回为空的问题
- 解决使用SDWebImage加载图片,图片为空的问题
- Xamarin.ios 解决new NSUrl 返回为空的方法。
- MenuItemCompat.getActionProvider 返回实例为空的解决
- 解决arcgisserver执行queryTask的时候,返回最多为500
- 解决从Android选择图片裁剪失败的一种情况
- 调用系统的图片裁剪无法返回
- android 实现图片的裁剪
- Android图片的裁剪功能
- Mysql命令行添加用户
- 表空间配额和UNLIMITED TABLESPACE权限
- Matlab实现批量处理图像的两种方法
- Cypher查询语言--Neo4j中的SQL(3)
- 修改eclipse中maven插件仓库地址
- Android--Miui6.0裁剪图片的时候返回为空的解决
- 七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC
- 调试存储过程也是有提交和回滚的
- 刻度盘的两种实现(一)
- 保留位置1
- ORA-01950: no privileges on tablespace 解决方法
- jQuery 字符串全部替换
- Cypher查询语言--Neo4j中的SQL(4)
- Strust2优点之全局异常处理器+拦截器