相机X Imagecapture.TakePicture功能在Android上不起作用12

发布于 2025-02-11 03:44:22 字数 1231 浏览 0 评论 0原文

在这里,我正在尝试使用Camerax拍摄照片,它可以完美地使用Android 12设备,但是当使用Android 12设备时,它无法正常工作。

 long x = System.currentTimeMillis();


            String fileName = getExternalFilesDir(null) + "" + x + ".jpg";


            File file = new File(fileName);

            ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(file).build();
            imageCapture.takePicture(outputFileOptions, executor, new ImageCapture.OnImageSavedCallback() {


                @Override
                public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
                    Log.e("xxxx", "yyy");
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, "Image Saved successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                }

                @Override
                public void onError(@NonNull ImageCaptureException error) {
                    error.printStackTrace();
                }
            });

我调试了代码,并在OnError函数中放了一个制动点,但没有被调用

Here i'm trying to take pictures using camerax , it is working with below android 12 devices perfectly but when use android 12 device it is not working.

 long x = System.currentTimeMillis();


            String fileName = getExternalFilesDir(null) + "" + x + ".jpg";


            File file = new File(fileName);

            ImageCapture.OutputFileOptions outputFileOptions = new ImageCapture.OutputFileOptions.Builder(file).build();
            imageCapture.takePicture(outputFileOptions, executor, new ImageCapture.OnImageSavedCallback() {


                @Override
                public void onImageSaved(@NonNull ImageCapture.OutputFileResults outputFileResults) {
                    Log.e("xxxx", "yyy");
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(MainActivity.this, "Image Saved successfully", Toast.LENGTH_SHORT).show();
                        }
                    });
                }

                @Override
                public void onError(@NonNull ImageCaptureException error) {
                    error.printStackTrace();
                }
            });

i debugged the code and put a brake-point in onError function , but it is not called

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文