flutter android 权限,android – 通过Flutter插件在ExternalStorageDirectory访问权限被拒绝...

我写了一个插件来通过Dart访问

Android上的ExternalStorageDirectory.

这个插件的android特定代码:

@Override

public void onMethodCall(MethodCall call,Result result) {

if (call.method.equals("getUserDataDirectory")) {

String path = Environment.getExternalStorageDirectory().getAbsolutePath();

result.success(path);

} else {

result.notImplemented();

}

}

返回的路径是正确的存储/模拟/ 0.但现在如果我尝试迭代抛出目录我得到一个权限被拒绝.

error.log中

[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:

E/flutter ( 3381): FileSystemException: Directory listing Failed,path = '/storage/emulated/0/' (OS Error: Permission denied,errno = 13)

E/flutter ( 3381): #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:32)

E/flutter ( 3381): #1 _Directory.listSync (directory_impl.dart:214)

E/flutter ( 3381): #2 _MyAppState.initPathRequest (/data/user/0/com.yourcompany.userdatadirectoryexample/cache/exampleIAKNFP/example/lib/main.dart:34:25)

main.dart

path = await Userdatadirectory.getUserDataDirectory;

var dir = new Directory(path);

List contents = dir.listSync();

for (var fileOrDir in contents) {

print(fileOrDir.path);

}

我的示例/ android / app / src / AndroidManifest.xml包含以下额外的提交:

这里有什么问题?

你可能感兴趣的:(flutter,android,权限)