Search code examples
androidimageandroid-intentcrop

com.android.camera.action.CROP activity not updating its image


I picked and image from gallery using ACTION_PICK intent and then opened it using com.android.camera.action.CROP intent, it worked fine. But when I overwritten that image file with another image and then opened CROP activity it was still showing previous image(image before overwriting file).

Similar problem occurred with me when I used ACTION_VIEW to preview overwritten image in gallery, the gallery image thumbnail and preview was not updated. So i used

File f=new File(getWorkingDirectory() + File.separator +  "temp.jpg");
tempFile=Uri.fromFile(f);    
Intent mediaScanIntent=new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
mediaScanIntent.setData(tempFile);
parentClass.sendBroadcast(mediaScanIntent);

and this solved the problem for gallery(but not for crop activity).

My question is how should I tell crop activity that image has changed(overwritten completely with a new image), so that when I call again startActivityForResult() for CROP action it displays overwritten image.

Please help me. I am stuck!


Solution

  • com.android.camera.action.CROP is not official android intent. Apps like gallery and camera support it but there are many devices where this intent is not supported. here. Have a look at this blog post by @commonsware. I have answered cropping image using a library in this SO post.