What to do when - java.io.FileNotFoundException: No content provider?

后端 未结 3 1072
情深已故
情深已故 2020-12-13 23:15

when I try to attach a file to an email, I get a java.io.FileNotFoundException: No content provider logcat output. If anyone could tell me what I am doing wrong or what I s

相关标签:
3条回答
  • 2020-12-13 23:40

    You can also try this:

    Uri.fromFile(new File(your image path));
    
    0 讨论(0)
  • 2020-12-13 23:57

    Method to save an bitmap to a file

      private fun bitmapToFile(bitmap:Bitmap): Uri {
            // Get the context wrapper
            val wrapper = ContextWrapper(applicationContext)
    
            // Initialize a new file instance to save bitmap object
            var file = wrapper.getDir("Images",Context.MODE_PRIVATE)
            file = File(file,"${UUID.randomUUID()}.jpg")
    
            try{
                // Compress the bitmap and save in jpg format
                val stream:OutputStream = FileOutputStream(file)
                bitmap.compress(Bitmap.CompressFormat.JPEG,100,stream)
                stream.flush()
                stream.close()
            }catch (e:IOException){
                e.printStackTrace()
            }
    
            // Return the saved bitmap uri
            return Uri.parse(file.absolutePath)
        }
    
    0 讨论(0)
  • 2020-12-14 00:00

    Maybe you should pass an uri of the form file:///sdcard/Video0006.mp4.

    0 讨论(0)
提交回复
热议问题