Pick image for crop from gallery and camera it\'s done for below Android 7.0 but in Android Nought it crashes in camera. I use fileprovider for it but doesn\'t work.
This worked for me like charm for Marshmallow as well as for 7.1.2 (Naugat)
Write code as described in this step for both, Marshmallow as well as for 7.1.2 (Naugat)
com.android.camera.action.CROP (which is actually not recommanded but still many developer use), then you can call these methods with URI in old style. i.e. Uri.fromFile(file)cropIntent.setDataAndType(Uri.fromFile(file), "image/*");
and
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
along with other methods (please search how to call intent com.android.camera.action.CROP)
And, finally before calling startActivityForResult(cropIntent, CROP_ACTIVITY_CODE)
make sure to write this this...
if(Build.VERSION.SDK_INT>=24)
{
try
{
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
m.invoke(null);
}
catch(Exception e)
{
e.printStackTrace();
}
}
That's it! I hope it helps someone.