-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
安卓13适配问题 #142
Comments
同问呀 |
调用前自行判断下权限
|
好的 收到 谢谢
原始邮件
发件人:"杨培星"< ***@***.*** >;
发件时间:2023/12/13 16:50
收件人:"yangpeixing/YImagePicker"< ***@***.*** >;
抄送人:"liguangluo"< ***@***.*** >;"Comment"< ***@***.*** >;
主题:Re: [yangpeixing/YImagePicker] 安卓13适配问题 (Issue #142)
调用前自行判断下权限
` private boolean hasStoragePermissions(Context context) {
//版本判断,如果比android 13 就走正常的权限获取
if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU){
int readPermission = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE);
int writePermission = ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE);
return readPermission == PackageManager.PERMISSION_GRANTED && writePermission == PackageManager.PERMISSION_GRANTED;
}else{
int audioPermission = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_AUDIO);
int imagePermission = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_IMAGES);
int videoPermission = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_MEDIA_VIDEO);
return audioPermission == PackageManager.PERMISSION_GRANTED && imagePermission == PackageManager.PERMISSION_GRANTED && videoPermission == PackageManager.PERMISSION_GRANTED;
}
}
private void requestStoragePermissions(Context context) { String [] permissions; if(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU){ permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}; }else{ permissions = new String[]{Manifest.permission.READ_MEDIA_AUDIO, Manifest.permission.READ_MEDIA_IMAGES,Manifest.permission.READ_MEDIA_VIDEO}; } ActivityCompat.requestPermissions((Activity) context, permissions, STORAGE_PERMISSION_REQUEST_CODE); }`
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
不准备升级依赖了吗? |
安卓13的读取权限做了修正,有作者有考虑适配吗
The text was updated successfully, but these errors were encountered: