Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 摄像头API安卓10_Java_Android_Android Camera2_Android 10.0 - Fatal编程技术网

Java 摄像头API安卓10

Java 摄像头API安卓10,java,android,android-camera2,android-10.0,Java,Android,Android Camera2,Android 10.0,拍摄图像时显示错误,我已授予设备的读写存储权限 我在安卓10中使用照相机意图拍照,但显示以下错误 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); ContentResolver resolver = getConte


拍摄图像时显示错误,我已授予设备的读写存储权限 我在安卓10中使用照相机意图拍照,但显示以下错误

if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {

                        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        ContentResolver resolver = getContext().getContentResolver();
                        ContentValues contentValues = new ContentValues();
                        contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "temp");
                        contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/png");
                        contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, "DCIM/" + "TEMP");
                        Uri imageUri123 = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
                        intent.putExtra(MediaStore.EXTRA_OUTPUT,
                                imageUri123);
                        startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);


                    }else {
                        File photo = new File(Environment.getExternalStorageDirectory(), "temp.jpg");
                        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                        cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Build.VERSION.SDK_INT >= Build.VERSION_CODES.M?getOutputMediaFileUri(getActivity(), photo):Uri.fromFile(photo));
                        startActivityForResult(cameraIntent, REQUEST_IMAGE_CAPTURE);
                    }

在那里也授予权限。你尝试做的不是Camera API,而是尝试使用intent启动Camera应用程序。我想使用android 10的Camera API,任何用于所有版本的最佳摄像头也在那里授予权限。您尝试的不是摄像头API,而是尝试使用intent启动摄像头应用程序。我想使用android 10的摄像头API,任何用于所有版本的最佳摄像头