RedApparat / Fotoapparat

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

Camera.PictureCallback not called for device Xiaomi Mi 4 LTE, Realme C1 #363

Closed tommyaja closed 5 years ago

tommyaja commented 5 years ago

Hi everyone, I'm new to android, and now I'm try to create an apps that will open camera, and this is how I initialize :

    fotoapparat = Fotoapparat.with(this)
            .into(cameraView)
            .focusMode(firstAvailable(
                    continuousFocusPicture(),
                    autoFocus(),
                    fixed()
            ))
            .flash(off())
            .lensPosition(back())
            .jpegQuality(manualJpegQuality(80))
            .cameraErrorCallback(new CameraErrorListener() {
                @Override
                public void onError(CameraException ex) {
                    ex.printStackTrace();
                    SessionController.setCheckinDefault(true);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            final Intent intent = new Intent();
                            if (singleAdsType >= 0) {
                                intent.putExtra("single_ads_type", singleAdsType);
                            }
                            setResult(RESULT_OK, intent);
                            finish();
                        }
                    });
                }
            })
            .build();

Inside capture button :

@OnClick(R.id.btn_capture)
void doCapture() {
    if (!isClickValid(3000)) {
        return;
    }
    showLoading();

    final PhotoResult photoResult = fotoapparat.takePicture();
    photoResult.toBitmap(scaled(0.25f))
            .whenDone(new WhenDoneListener<BitmapPhoto>() {
                @Override
                public void whenDone(BitmapPhoto bitmapPhoto) {

                    setCaptureResult(_imageKey, file, bitmapPhoto.bitmap, bitmapPhoto.rotationDegrees * -1);

                }
            });
}

I've clean & rebuild, no error, but the code inside whenDone method still never get called, and then, I try to clone Fotoapparat sample and running to those device, but still no luck.

After an hour I logging the flow, now I know the Camera.PictureCallback never called on those both device, but my other test device Lenovo K4 Note, Camera.PictureCallback get called.

Am I do some mistake? or anyone have some kind error like me? Thanks.

khandilist commented 5 years ago

I tried on Realme C1, it only works with front camera, but no any action using back camera. Tracing into kotlin source code, also confirm that android built-in function takepicture -> PictureCallback.onPictureTaken never called. Any one find solutions?