Flutter Android 12-获取文件有问题



我使用Flutter开发Android应用程序,而我的Android version is 12。我读取Android内置存储目录,可以看到目录,但是看不到txt, md, and PDF文件不可用

这是我的AndroidManifest.xml文件代码:


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_app">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:preserveLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true"
android:label="flutter_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

我是这样获取列表的:

Directory dir = Directory('/storage/emulated/0/docs');
List<FileSystemEntity> entities = dir.listSync(recursive: true);

我的应用程序permissions显示我已经获得了读写移动存储的权限。

https://github.com/dart-lang/sdk/issues/44848

设置在隐私比;权限经理>文件和媒体,选择你的应用程序,点击允许所有文件

相关内容

  • 没有找到相关文章

最新更新