getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) cause ANR on android 11 and android 12

193 views Asked by At

this is my code

fun createDirDownload(): File {

        val fileDir = activity?.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS)!!
        if (!fileDir.exists()) {
            fileDir.mkdirs()
        }

        return fileDir
    }

The firebase crashlytics shows this method: getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) caused ANR. But I don't know why and how to solve the problem.

How to solve this issue?

0

There are 0 answers