FileNotFoundException when cropping a photo
- by James G
I'm trying to crop a photo to use in a Live Wallpaper but I'm getting a FileNotFoundException when the crop activity tries to save my new cropped image. This is the code I'm using:
File file = new File(getFilesDir(), "wallpaper.jpg");
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setData(uri);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
intent.putExtra("outputX", metrics.widthPixels * 2);
intent.putExtra("outputY", metrics.heightPixels);
intent.putExtra("aspectX", metrics.widthPixels * 2);
intent.putExtra("aspectY", metrics.heightPixels);
intent.putExtra("scale", true);
intent.putExtra("noFaceDetection", true);
intent.putExtra("output", Uri.parse("file:/" + file.getAbsolutePath()));
startActivityForResult(intent, REQUEST_CROP_IMAGE);
The wallpaper.jpg file seems to exist on DDMS file explorer so I'm not sure what I'm doing wrong. Any advice is greatly appreciated.