兼容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.CAMERA" />
<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.WRITE_EXTERNAL_STORAGE" />
<uses-permission

View File

@ -49,6 +49,15 @@ public class ProcessImageUtil extends ProcessResultUtil {
Manifest.permission.READ_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() {
@Override
public void run() {

View File

@ -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[]{
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
}, mStartLiveRunnable);
};
}
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[]{
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
}, mStartVideoRunnable);
};
}
mProcessResultUtil.requestPermissions(permissions, mStartVideoRunnable);
} else {
ToastUtil.show(getString(R.string.only_open_anchor));
}