Resolveuri Failed On Bad Bitmap Uri On Camera
I'm having troubles while trying to create a bitmap from a Camera AND an Image Picker. I used a code that creates an Uri by the Camera so I added a condition to my function that al
Solution 1:
privatevoidonClickCamera() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(context.getPackageManager()) != null) {
ContentValues values = new ContentValues(1);
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpg");
fileUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
startActivityForResult(takePictureIntent, SELECT_PICTURE_CAMARA);
} else {
Toast.makeText(this, getString(R.string.error_no_camera), Toast.LENGTH_LONG).show();
}
}
try this in your takePicture clickListener
Solution 2:
You can try creating temporary file like below. In onOnClick event
Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);
Filef=newFile(android.os.Environment.getExternalStorageDirectory(), "temp.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
and for onActivityResult
Filef=newFile(android.os.Environment.getExternalStorageDirectory(), "temp.jpg");
BitmapFactory.OptionsbitmapOptions=newBitmapFactory.Options();
Bitmapbitmap= BitmapFactory.decodeFile(f.getAbsolutePath(), bitmapOptions);
Post a Comment for "Resolveuri Failed On Bad Bitmap Uri On Camera"