首页 > 解决方案 > 如何在android中使用Camera 2 api保存文件

问题描述

像这样使用camera2 api im保存文件

if (Build.VERSION.SDK_INT <=Build.VERSION_CODES.P){
                    final String folderPath = Environment.getExternalStorageDirectory() + "/Pikpap/";
                     file1 = new File(folderPath);
                } else{
                    file1 = new File( CameraFragment.view.getContext().getExternalFilesDir()+ "/Pikpap/");
                }
                if (!file1.exists()) {
                    file1.mkdirs();
                }
                String fullName = file1.getAbsolutePath() + "Pikpap" + currentTime+name + ".jpg";
                File file = new File(fullName);

但有时文件未保存并且图像视图上的图像空白设置此问题在所有设备上创建

标签: javaandroid

解决方案


推荐阅读