QRCodeReaderView icon indicating copy to clipboard operation
QRCodeReaderView copied to clipboard

Frames are not processed after lock/unlock of the device

Open Chrison opened this issue 8 years ago • 2 comments

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

  1. Send the application on the background pressing the home button
  2. 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.

Chrison avatar Nov 11 '16 10:11 Chrison

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.

ptty avatar Nov 27 '16 12:11 ptty

thanks, you saved my time!

molhaMaleh avatar Feb 22 '17 06:02 molhaMaleh