Commit c12aa3dd by YKai

feat: 安卓sdk升级往相册存储图片,判断是否大于29

parent d67e2f08
......@@ -33,7 +33,7 @@ ext {
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.41.59",
"ydl-platform" : "0.0.41.60",
//第二步 若干
"ydl-webview" : "0.0.38.57",
......
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.util.Base64;
import com.yidianling.common.tools.ToastUtil;
......@@ -14,9 +15,14 @@ public class ImageUtil {
public static boolean savePicture(Context context, String base64DataStr) {
// 去掉base64中的前缀
// String base64Str = base64DataStr.substring(base64DataStr.indexOf(",")+1, base64DataStr.length());
File appDir = new File(Environment.getExternalStorageDirectory(), "Camera");// 图片保存的文件夹的名称
File file;
if (Build.VERSION.SDK_INT > 29) { // Android 11 获取存储路径错误 android.system.ErrnoException: open failed: EPERM (Operation not permitted),Android11 不能获取sdcard通用空间路径
file = context.getExternalFilesDir(null);
} else {
file = Environment.getExternalStorageDirectory();
}
File appDir = new File(file, "Camera");// 图片保存的文件夹的名称
if (!appDir.exists()) {
appDir.mkdir();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment