From 0a442e7df9601967ea4775b33b3f6693bf343274 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 23 Aug 2023 17:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9Android13=E6=9D=83=E9=99=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 + .../yunbao/common/utils/ProcessImageUtil.java | 9 ++++ .../main/dialog/MainStartDialogFragment.java | 45 ++++++++++++++----- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c6e47c1a3..9e513cf6e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -62,6 +62,8 @@ + + = Build.VERSION_CODES.TIRAMISU) { + mCameraPermissions = new String[]{ + Manifest.permission.READ_MEDIA_IMAGES, + Manifest.permission.CAMERA + }; + mAlumbPermissions = new String[]{ + Manifest.permission.READ_MEDIA_IMAGES, + }; + } mCameraPermissionCallback = new Runnable() { @Override public void run() { diff --git a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java index 74a2bbf45..5c36c21d7 100644 --- a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java +++ b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java @@ -6,6 +6,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.app.Dialog; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.view.Gravity; @@ -160,12 +161,22 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O public void onLiveClick() { boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType(); if (isAnchor) { - mProcessResultUtil.requestPermissions(new String[]{ - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.CAMERA, - Manifest.permission.RECORD_AUDIO - }, mStartLiveRunnable); + String[] permissions; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + permissions=new String[]{ + Manifest.permission.READ_MEDIA_IMAGES, + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO + }; + }else{ + permissions=new String[]{ + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO + }; + } + mProcessResultUtil.requestPermissions(permissions, mStartLiveRunnable); } else { ToastUtil.show(getString(R.string.only_open_anchor)); } @@ -176,12 +187,22 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O public void onVideoClick() { boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType(); if (isAnchor) { - mProcessResultUtil.requestPermissions(new String[]{ - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.CAMERA, - Manifest.permission.RECORD_AUDIO - }, mStartVideoRunnable); + String[] permissions; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + permissions=new String[]{ + Manifest.permission.READ_MEDIA_IMAGES, + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO + }; + }else{ + permissions=new String[]{ + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.CAMERA, + Manifest.permission.RECORD_AUDIO + }; + } + mProcessResultUtil.requestPermissions(permissions, mStartVideoRunnable); } else { ToastUtil.show(getString(R.string.only_open_anchor)); }