diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5d4891e33..5f2f0f850 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -80,6 +80,7 @@ + = Build.VERSION_CODES.N) { @@ -159,6 +161,22 @@ public class LogUtil { share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); context.startActivity(Intent.createChooser(share, "分享文件")); } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if(!Environment.isExternalStorageManager()){ + Intent intent=new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); + context.startActivity(intent); + } + } + File out = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + file.getName()); + file.renameTo(out); + Log.i("文件", "shareFile: "+out.getAbsolutePath()+" "+out.exists()); + try { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + Files.copy(file.toPath(),out.toPath()); + } + } catch (Exception e) { + e.printStackTrace(); + } } }