原因:三星手机的存储路径和其他oppo,vivo,华为等不一样。
解决方法如下:
public File saveBitmapFile(Bitmap bitmap) throws FileNotFoundException { long currentTime = Calendar.getInstance().getTimeInMillis(); String vendor = Build.MANUFACTURER; //判断是否为三星手机 if (vendor != null && vendor.toLowerCase().contains("samsung")) {
//三星手机可以找到的文件需要用/mnt/sdcard路径 file1 = new File("/mnt/sdcard", String.valueOf(currentTime)); } else {
//正常手机是这样,对三星就是不正常各种问题
file1 = new File(PATH, String.valueOf(currentTime));//将要保存图片的路径
}
try {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file1));
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
return file1;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
本文提供了一种针对三星手机的特殊存储路径解决方案,通过判断手机制造商来选择正确的存储路径,确保图片能够正确保存到三星手机中。适用于开发过程中遇到三星手机存储问题的开发者。

被折叠的 条评论
为什么被折叠?



