为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
谁能解释为什么这个结果是无限循环?
var name = true;
var soloLoop = function () {
while (name) {
console.log(name);
name = false;
}
};
soloLoop();
Run Code Online (Sandbox Code Playgroud)