兼容Android13权限问题

This commit is contained in:
zlzw 2023-08-23 17:02:16 +08:00
parent 75b176a81e
commit 0a442e7df9
3 changed files with 44 additions and 12 deletions

View File

@ -62,6 +62,8 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" /> <uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission <uses-permission

View File

@ -49,6 +49,15 @@ public class ProcessImageUtil extends ProcessResultUtil {
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE,
}; };
if (Build.VERSION.SDK_INT >= 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() { mCameraPermissionCallback = new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -6,6 +6,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.view.Gravity; import android.view.Gravity;
@ -160,12 +161,22 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O
public void onLiveClick() { public void onLiveClick() {
boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType(); boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType();
if (isAnchor) { if (isAnchor) {
mProcessResultUtil.requestPermissions(new String[]{ String[] permissions;
Manifest.permission.READ_EXTERNAL_STORAGE, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Manifest.permission.WRITE_EXTERNAL_STORAGE, permissions=new String[]{
Manifest.permission.CAMERA, Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.RECORD_AUDIO Manifest.permission.CAMERA,
}, mStartLiveRunnable); 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 { } else {
ToastUtil.show(getString(R.string.only_open_anchor)); ToastUtil.show(getString(R.string.only_open_anchor));
} }
@ -176,12 +187,22 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O
public void onVideoClick() { public void onVideoClick() {
boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType(); boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType();
if (isAnchor) { if (isAnchor) {
mProcessResultUtil.requestPermissions(new String[]{ String[] permissions;
Manifest.permission.READ_EXTERNAL_STORAGE, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Manifest.permission.WRITE_EXTERNAL_STORAGE, permissions=new String[]{
Manifest.permission.CAMERA, Manifest.permission.READ_MEDIA_IMAGES,
Manifest.permission.RECORD_AUDIO Manifest.permission.CAMERA,
}, mStartVideoRunnable); 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 { } else {
ToastUtil.show(getString(R.string.only_open_anchor)); ToastUtil.show(getString(R.string.only_open_anchor));
} }