小编Din*_*inu的帖子

Android APIv29 FileNotFoundException EACCES(权限被拒绝)

为targetSdkVersion v29构建时,我无法访问存储。

这是我的gradle配置:

    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    ...
        minSdkVersion 15
        targetSdkVersion 29
Run Code Online (Sandbox Code Playgroud)

请注意,WRITE_EXTERNAL_STORAGE为进行构建时,将授予权限并且相同的设置可以正常工作targetSdkVersion 28。

这是我的实现:

        val outputFolder = File(baseFolder + File.separator + "Output Folder")
        if (!outputFolder.exists()) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                Files.createDirectory(outputFolder.toPath()) //This allways returns false with targetSdkVersion 29
            } else {
                if (!outputFolder.mkdirs()) {
                    Log.e("SaveRaw", "Unable to create folder for audio recording")
                }
            }
        }

        outputFile = File("$baseFolder/Output Folder/$filename")
        try {
            fileOutputStream = FileOutputStream(outputFile)
        } catch (e: FileNotFoundException) {
            e.printStackTrace() // allways throwing exception …
Run Code Online (Sandbox Code Playgroud)

android filenotfoundexception kotlin android-external-storage android-api-levels

3
推荐指数
1
解决办法
212
查看次数

浏览器控制台中的无限循环

谁能解释为什么这个结果是无限循环?

var name = true;
var soloLoop = function () {
  while (name) {
     console.log(name);
     name = false;
  }
};

soloLoop();
Run Code Online (Sandbox Code Playgroud)
  • 注1:只能在浏览器的控制台中复制.
  • 注2:只能用变量"name"重现.

javascript infinite-loop

1
推荐指数
1
解决办法
116
查看次数