1

enter image description here
Error showing while capturing image ,I already give the read write storage permission of device I am using camera intent for taking photo in android 10, But shows following error

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {

                        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        ContentResolver resolver = getContext().getContentResolver();
                        ContentValues contentValues = new ContentValues();
                        contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "temp");
                        contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/png");
                        contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, "DCIM/" + "TEMP");
                        Uri imageUri123 = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
                        intent.putExtra(MediaStore.EXTRA_OUTPUT,
                                imageUri123);
                        startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);


                    }else {
                        File photo = new File(Environment.getExternalStorageDirectory(), "temp.jpg");
                        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                        cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Build.VERSION.SDK_INT >= Build.VERSION_CODES.M?getOutputMediaFileUri(getActivity(), photo):Uri.fromFile(photo));
                        startActivityForResult(cameraIntent, REQUEST_IMAGE_CAPTURE);
                    }
rawhost
  • 144
  • 1
  • 6

0 Answers0