RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.83k stars 407 forks source link

CameraView not working #420

Open SherazAli-67 opened 2 years ago

SherazAli-67 commented 2 years ago

Hi guys,

I was working on project that implements Fotoapparat it worked properly earlier but now when I am back for testing, Cameraview is not showing camera to capture image but capturing button is visible.

Here is the code


new Handler().postDelayed(() -> {
            foto = Fotoapparat
                    .with(getApplicationContext())
                    .into(camera_view)           // view which will draw the camera preview
                    .previewScaleType(ScaleType.CenterCrop)  // we want the preview to fill the view
                    .photoResolution(ResolutionSelectorsKt.highestResolution())   // we want to have the biggest photo possible
                    .lensPosition(fromScreen.equals("profilePicture") ? front() : back())       // we want back camera
                    .focusMode(SelectorsKt.firstAvailable(  // (optional) use the first focus mode which is supported by device
                            FocusModeSelectorsKt.continuousFocusPicture(),
                            FocusModeSelectorsKt.autoFocus(),        // in case if continuous focus is not available on device, auto focus will be used
                            FocusModeSelectorsKt.fixed()             // if even auto focus is not available - fixed focus mode will be used
                        ))
                        .flash(SelectorsKt.firstAvailable(      // (optional) sFimilar to how it is done for focus mode, this time for flash
                                FlashSelectorsKt.autoRedEye(),
                                FlashSelectorsKt.autoFlash(),
                                FlashSelectorsKt.off()
                        ))
                        .logger(LoggersKt.loggers(            // (optional) we want to log camera events in 2 places at once
                                LoggersKt.logcat(),           // ... in logcat
                                LoggersKt.fileLogger(this)    // ... and to file
                        ))
                    .cameraErrorCallback(e -> {
                        e.printStackTrace();
                        Log.d("TAG", "Error: "+e.getMessage());
                        Toast.makeText(this, "Chip[)a: "+e.getMessage(), Toast.LENGTH_SHORT).show();
                    })
                    .build();
        }, 200);

How did you initialize FA?

@Override
    protected void onStart() {
        super.onStart();
        //cameraKitView.onStart();
        if (foto != null) {
            foto.start();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (foto != null) {
            foto.stop();
        }
    }

When I run application this is what I am getting

fotoapparat issue

andresteves commented 1 year ago

Same issue, have you managed to solve it?

JohnLopen commented 3 months ago

The same issue on Google Pixel 6 Pro. Any solution to this one please?