Here is my code:
private Bitmap getBitmap(Uri selectedimg) throws IOException {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 3;
AssetFileDescriptor fileDescriptor = null;
Log.d("selectedimg"," selectedimg = " + selectedimg);
fileDescriptor =
getActivity().getContentResolver().openAssetFileDescriptor(selectedimg, "r");
Bitmap original
= BitmapFactory.decodeFileDescriptor(
fileDescriptor.getFileDescriptor(), null, options);
return original;
}
I safe the bitmap after i launch the camera intent with the result image. Than i try to read the image into a bitmap. The image is there and not damaged.
I get the error:
> 08-10 15:26:58.578 26729-26729/com.ebed.scannerod W/System.err: java.io.FileNotFoundException: Permission denied
08-10 15:26:58.578 26729-26729/com.ebed.scannerod W/System.err: at android.os.Parcel.openFileDescriptor(Native Method)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:270)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:200)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:970)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:898)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at com.scanlibrary.PickImageFragment$override.getBitmap(PickImageFragment.java:159)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at com.scanlibrary.PickImageFragment$override.onActivityResult(PickImageFragment.java:130)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at com.scanlibrary.PickImageFragment$override.access$dispatch(PickImageFragment.java)
08-10 15:26:58.579 26729-26729/com.ebed.scannerod W/System.err: at com.scanlibrary.PickImageFragment.onActivityResult(PickImageFragment.java:0)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:6537)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:3772)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3819)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.app.ActivityThread.access$1400(ActivityThread.java:159)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1433)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
08-10 15:26:58.580 26729-26729/com.ebed.scannerod W/System.err: at android.os.Looper.loop(Looper.java:152)
08-10 15:26:58.581 26729-26729/com.ebed.scannerod W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5507)
08-10 15:26:58.581 26729-26729/com.ebed.scannerod W/System.err: at java.lang.reflect.Method.invoke(Native Method)
08-10 15:26:58.581 26729-26729/com.ebed.scannerod W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
08-10 15:26:58.581 26729-26729/com.ebed.scannerod W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
It says that i dont have the permission to do this but i declaired all Premissions i need (Camera Read and Write) in the Manifest file. I run it API 24.
I dont know what i could do to solve this problem.
Thanks for your time.