Camera not working/saving when using Cache Uri as MediaStore.EXTRA_OUTPUT

后端 未结 3 481
滥情空心
滥情空心 2020-12-29 05:02

I am trying to get the full image after taking a picture from a Fragment.

If I use the Uri from the file (Uri.fromFile(file)), the camera w

3条回答
  •  既然无缘
    2020-12-29 05:45

    Why not saving it in a new File

        final File root = new File(Environment.getExternalStorageDirectory() + File.separator + "MyDir" + File.separator);
        root.mkdirs();
        final String fname = "img_"+ System.currentTimeMillis() + ".jpg";
        final File sdImageMainDirectory = new File(root, fname);
        mImageUri = Uri.fromFile(sdImageMainDirectory);
    

    And then pass that uri to the intent

        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
    

提交回复
热议问题