简体   繁体   English

当我将目标 api 设置为 29 时,未创建 Android 设备目录

[英]Android device directory not creating when i set target api as 29

i have a mobile app in cordova, in that i create directory, if i use Target Api 28, it will create folder, in same time if set Target Api as 29,directory never creating, i am using following code to create directory in internal storage.我在 cordova 中有一个移动应用程序,在那里我创建目录,如果我使用 Target Api 28,它将创建文件夹,同时如果在内部设置 Target Z72664DC0959F3B0C04891F8C7046A9F 目录,创建以下代码为 293,贮存。

 if (device.platform.toLowerCase() == "android") {
            window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, onFileSystemSuccess, onError);
        } else {
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onError);
        }
        
        function onFileSystemSuccess(fileSystem) {
        var entry = "";
        if (device.platform.toLowerCase() == "android") {
            entry = fileSystem;
        } else {
            entry = fileSystem.root;
        }
        entry.getDirectory("smfolder", {
            create: true,
            exclusive: false
        }, onGetDirectorySuccess, onGetDirectoryFail);
    };



    function onError(e) {
        alert("Fail to get folder");
    };

This is config.xml screenshot: http://prntscr.com/w53qgh When i upload in Play Store, it will ask to set Target Api level as 29, then only can upload, so i need to set API as 29, is there any thing need to add in config or android manifest file? This is config.xml screenshot: http://prntscr.com/w53qgh When i upload in Play Store, it will ask to set Target Api level as 29, then only can upload, so i need to set API as 29, is there需要在配置或 android 清单文件中添加任何内容吗? or need to add permission to use API 29.或者需要添加权限才能使用 API 29.

Appreciate your assistance since i have been stuck in this for few days now.感谢您的帮助,因为我已经被困在这几天了。

Regards,问候,

Aravind阿拉文

Although I am not a Cordova expert, it seems that the issue is because of Scoped Storage introduced as part of API 29 (Android 10)虽然我不是 Cordova 专家,但问题似乎是因为作为 API 29 (Android 10) 的一部分引入的范围存储

It adds some restrictions on how your app can read/write to file system.它对您的应用程序如何读取/写入文件系统添加了一些限制。 However, as a work-around, you can opt-out of Scoped Storage to work just like API 28.但是,作为一种变通方法,您可以选择退出 Scoped Storage 以像 API 28 一样工作。

Just add android:requestLegacyExternalStorage="true" in manifest file's application tag to opt-out of scoped storage.只需在清单文件的应用程序标签中添加android:requestLegacyExternalStorage="true"即可选择退出范围存储。 It should solve your problem.它应该可以解决您的问题。

Make sure your compileSdkVersion is set to 29 to use this attribute.确保您的 compileSdkVersion 设置为 29 以使用此属性。

Please note that if you target API 30 (Android 11), this flag will be ignored by the system and you have to make your app compatible with scoped storage.请注意,如果您以 API 30 (Android 11) 为目标,系统将忽略此标志,您必须使您的应用与范围存储兼容。

More on:https://developer.android.com/about/versions/11/privacy/storage更多信息:https://developer.android.com/about/versions/11/privacy/storage

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Delphi 10.3.3 上的目标 Android API 29 - Target Android API 29 on Delphi 10.3.3 Android - 在具有 api 29 的设备上未触发 AlarmManager - Android - AlarmManager is not triggered on a device with api 29 为目标 API 级别 29 编译时,在 Android API 级别 &lt; 24 上访问 NMEA? - Accessing NMEA on Android API level < 24 when compiled for target API level 29? Android 10 (api 29) 中没有这样的文件或目录 - No such file or directory in Android 10 (api 29) 尝试安装 Cordova Android 平台 9 和目标 Android ZDB97444291083CA814DZ 时出现错误“无法从平台加载 PlatformApi” - Error 'Unable to load PlatformApi from the platform' when trying to install Cordova Android Platform 9 and target Android API 29 当应用程序在后台 xamarin forms android 应用程序在升级目标 Z8A5DA52ED126447D359E70C05721AA8 时,后台位置不起作用 - background location not working when app in background xamarin forms android app when upgrade target api to 29 FFMPEG 命令在设置项目的目标 SDK 版本 29 时不起作用(Android Q 问题) - FFMPEG command is not Working when set project's target SDK version 29(Android Q issue) 在 Android Api 29 中设置自定义铃声 - set custom ring tone in Android Api 29 当我将项目从 SDK 版本 28 设置为目标 SDK 版本 29 时,WebView 不起作用 - WebView is not working, when I set project to Target SDK Version 29 from SDK version 28 如何处理由 PC 创建的 Android 设备上的文件? API 级别 29 - How do I handle files on Android device that are created by a PC? API level 29
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM