dlazaro66 / QRCodeReaderView

Modification of ZXING Barcode Scanner project for easy Android QR-Code detection and AR purposes
1.9k stars 491 forks source link

Frames are not processed after lock/unlock of the device #92

Open Chrison opened 8 years ago

Chrison commented 8 years ago

The problem can be reproduced with the following steps,

1) Start the application and let the camera preview to appear. 2) Press the power button of the tablet to lock the device 3) Press the power button of the tablet to unlock the device 4) Target a QR code The logs doesn't show any change on SurfaceView

The QR is not recognized

5) Send the application on the background pressing the home button 6) Open the application again The logs show $ surfaceDestroyed $ surfaceChanged

The QR is now recognized.

I found a workaround which fixes this when i change the SurfaceView visibility in onPause/onResume.

ptty commented 7 years ago

I am not sure about visibility approach as it probably remains camera active. I have investigated slightly and come to conclusion that SurfaceView lifecycle is not currently handled properly in lib, looks as a bug. What I have done to fix the problem is added in order to re-initialize SurfaceView

private QRCodeReaderView camera; ...

@Override protected void onResume() { super.onResume(); camera.surfaceCreated(camera.getHolder()); camera.startCamera(); }

Hope it helps.

molhaMaleh commented 7 years ago

thanks, you saved my time!