java.io.IOException:损坏的文件描述符

时间:2014-05-11 08:43:51

标签: java android image android-layout layout

我尝试拍照(来自相机)

使用以下代码

imageCaptureUri = file:///storage/emulated/0/myApp/ProfileImageCapture.tmp

imageFile是输出文件== /storage/emulated/0/myApp/ProfileImage.tmp

  private void cropImage(Uri imageCaptureUri) {
    // Use existing crop activity.
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(imageCaptureUri, AccountSignInDetails.IMAGE_UNSPECIFIED);

    // Specify the output path
    File imageFile =
        new File(ResManager.mAppDir, AccountSignInDetails.PROFILE_IMAGE_FILE);
    intent.putExtra("output", Uri.fromFile(imageFile));

    // Specify image size
    intent.putExtra("outputX", 100);
    intent.putExtra("outputY", 100);

    // Specify aspect ratio, 1:1
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("scale", true);
    intent.putExtra("return-data", true);
    // REQUEST_CODE_CROP_PHOTO is an integer tag you defined to
    // identify the activity in onActivityResult() when it returns
    mActivity.startActivityForResult(intent, ImageTaker.REQUEST_CODE_CROP_PHOTO);
  }

有时我收到以下log-cat错误:

我理解错误是针对imageCaptureUri

05-11 11:26:19.338: W/DecodeUtils(24836): java.io.IOException: broken file descriptor
05-11 11:26:19.338: W/DecodeUtils(24836):   at android.graphics.BitmapRegionDecoder.nativeNewInstance(Native Method)
05-11 11:26:19.338: W/DecodeUtils(24836):   at android.graphics.BitmapRegionDecoder.newInstance(BitmapRegionDecoder.java:88)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.data.DecodeUtils.createBitmapRegionDecoder(DecodeUtils.java:229)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:175)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:171)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.app.CropImage$LoadDataTask.run(CropImage.java:1023)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.app.CropImage$LoadDataTask.run(CropImage.java:1014)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.util.ThreadPool$Worker.run(ThreadPool.java:133)
05-11 11:26:19.338: W/DecodeUtils(24836):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-11 11:26:19.338: W/DecodeUtils(24836):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-11 11:26:19.338: W/DecodeUtils(24836):   at java.lang.Thread.run(Thread.java:856)
05-11 11:26:19.338: W/DecodeUtils(24836):   at com.android.gallery3d.util.PriorityThreadFactory$1.run(PriorityThreadFactory.java:44)

我怎样才能解决破碎的uri?

0 个答案:

没有答案