exposed beyond app through ClipData.Item.getUri

后端 未结 4 936
借酒劲吻你
借酒劲吻你 2020-11-28 03:39

I am trying to fix a problem after the new feature added in Android file system but I get this error:

android.os.FileUriExposedException: file:///storage/emu         


        
4条回答
  •  有刺的猬
    2020-11-28 04:22

    No required provider configuration into AndroidManifest only Camera and Storage permission should be permitted. Use the following code to start the camera:

    final int REQUEST_ACTION_CAMERA = 9;
    void openCamra() {
    Intent cameraImgIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    
    cameraImgIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID +".provider",
                    new File("your_file_name_with_dir")));
    startActivityForResult(cameraImgIntent, REQUEST_ACTION_CAMERA);
    }
    

    After capturing the image, you can find your captured image in:

    "your_file_name_with_dir"
    

提交回复
热议问题