From 3f9cf21b8f68ba5514d736e81cf982cf022b6552 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Sat, 12 Nov 2022 11:32:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E9=87=8F=E6=97=A5=E5=BF=97=E9=87=87?= =?UTF-8?q?=E9=9B=86=E7=B3=BB=E7=BB=9F=E6=94=B9=E4=B8=BA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E4=B8=89=E5=A4=A9=E5=86=85=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 1 + .../java/com/shayu/phonelive/AppContext.java | 2 +- .../com/shayu/phonelive/utils/LogUtils.java | 49 ++++++++++++------- .../java/com/yunbao/common/utils/LogUtil.java | 20 +++++++- 4 files changed, 53 insertions(+), 19 deletions(-) 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(); + } } }