Im having a trouble in my project when i click the camera the app crashes in android studio.
Note : my app denied in google play because i use MANAGE_EXTERNAL_STORAGE, so im finding a different approach in my project, can someone help me?
Here is my code:
private fun getPictureFile(): File {
val fileName = "${imgCounter + 1}.jpg"
val pathName= Environment.getExternalStoragePublicDirectory(IMAGE_TEMP_FOLDER).toString()
val imageDir = File(pathName)
var imageFile: File? = null
try {
if (!imageDir.exists()) {
imageDir.mkdirs()
}
imageFile = File(imageDir.toString() + File.separator + fileName)
imageFilePath = imageFile.toString()
} catch (e: Exception) {
e.printStackTrace()
}
return imageFile!!
}
and when i call the function val imageTaken = getPictureFile()
val output = FileOutputStream(imageTaken)
the camera crashes