I recently updated adobecreativesdk with the latest version to support Android Nougat. After i edit the image in the editor i try to get the edited bitmap using the following code in onActivityResult:
mImageUri = data.getParcelableExtra(AdobeImageIntent.EXTRA_OUTPUT_URI);
Bitmap bitmap = BitmapFactory.decodeFile(mImageUri.getPath());
if(bitmap!=null)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
imagebytes = baos.toByteArray();
PlayAnimation();
}
Before updating to the latest version I was using data.getData() instead of data.getParcelableExtra and it was working fine for Android Marshmallow. But now my bitmap is always returned as null. I have set the URI of the image just like how it has been mentioned in this post : https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en. I also tried resizing the bitmap using BitmapFactory.Options thinking maybe the image was too big. But it does not seem to be the case.
If you have Uri
to image it is better to read it via ContentResolver
:
Uri uri;
Context context;
try {
Bitmap bm = BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ContentResolver
handles underlying storage differences for you. It works equally fine with both file://
, content://
and other Uri
types.