FileUriExposedException when create separate folder for captured images

后端 未结 2 1087
礼貌的吻别
礼貌的吻别 2021-01-29 14:07

I am trying to store camera captured images at separate folder using below code but when i execute this code i am getting exception and i tried lot for getting solution but no u

2条回答
  •  盖世英雄少女心
    2021-01-29 14:35

    Instead of return Uri.fromFile(mediaFile); do

    return FileProvider.getUriForFile(MainActivity.this,
                                      BuildConfig.APPLICATION_ID + ".provider",
                                      mediaFile);
    

    That would require you to add a provider to the AndroidManifest:

    
    
        
      
     
    

    And then create a provider_paths.xml file in xml folder under res folder.

    
    
    
    
    

    Once refer this https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en

提交回复
热议问题