Raj*_*hah 7 android android-service android-fragments android-support-library android-studio

在Android 10&11 SDK 30中如何访问Android设备中的所有文件并授予允许管理所有文件的权限
我已经尝试requestLegacyExternalStorage、、defaultToDeviceProtectedStorage和许可,但没有reserveLegacyExternalStorage
工作MANAGE_EXTERNAL_STORAGE
sus*_*ngh 12
您可以使用下面的代码。这个对我有用。
if (SDK_INT >= Build.VERSION_CODES.R) {
if (Environment.isExternalStorageManager()) {
startActivity(new Intent(this, MainActivity.class));
} else { //request for the permission
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
} else {
//below android 11=======
startActivity(new Intent(this, MainActivity.class));
ActivityCompat.requestPermissions(this, new String[]{WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
}
Run Code Online (Sandbox Code Playgroud)
android:requestLegacyExternalStorage="true"并在menifest文件中添加行
Via*_*ann -2
你不被允许这样做。没有人是。不,您无法规避此限制。
您只能访问、编辑和删除应用程序自己的数据。欲了解更多信息,请阅读此处。https://developer.android.com/about/versions/11/privacy/storage
| 归档时间: |
|
| 查看次数: |
31707 次 |
| 最近记录: |