Reputation: 388
I am trying to CROP a photo in android, but my temp-photo file always empty(0kb) although I had picked a photo from my gallery.
This is my code :
File dir = new File(Environment.getExternalStorageDirectory(), "pictures/softtime");//save path
if (!dir.exists()) {
dir.mkdirs();
}
currentImageFile = new File(dir, System.currentTimeMillis()+".jpg");//path+filename
//Create if not exists
if (!currentImageFile.exists()) {
try {
currentImageFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
Intent intentGet = new Intent("android.intent.action.GET_CONTENT");
intentGet.setType("image/*");
intentGet.putExtra("crop",true);
intentGet.putExtra("scale",true);
intentGet.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(currentImageFile));
startActivityForResult(intentGet,CROP);
I have run this code at my phone , I found that There is a new file created after I pick a photo ,but the new file is empty (0kb).
what can i do ?
Thank you everyone for help.
Upvotes: 0
Views: 107
Reputation: 1006704
There is no requirement for ACTION_GET_CONTENT
activities to support some undocumented crop
extra. If you want to allow the user to crop an image, use an image cropping library.
Upvotes: 1