qreader
qreader copied to clipboard
Black screen when re opening app
I just copied all the codes from the sample project that is included here.
@Override
protected void onResume() {
super.onResume();
qReader.initAndStart(surfaceView);
}`
@Override
protected void onPause() {
super.onPause();
qReader.releaseAndCleanup();
}`
I think there's something wrong about the SurfaceView, currently tested on Kitkat and Marshmallow both have the same error.
-Thanks
the problem looks like https://stackoverflow.com/questions/11495842/how-surfaceholder-callbacks-are-related-to-activity-lifecycle.
I did resolve this issue by using a FrameLayout instead of SurfaceView. In my onResume i reload the data (remove all views of FrameLayout and add the SurfaceView to the FrameLayout)
binding.frameSurface.removeAllViews(); surfaceView = new SurfaceView(getContext()); binding.frameSurface.addView(surfaceView)
There must be a better solution, but it works for now.
I check if the camera is running, and if it's false, i started again. @ralphgabrielle
@Override
protected void onResume() {
super.onResume();
// Init and Start with SurfaceView
// -------------------------------
qrEader.initAndStart(mySurfaceView);
if (!qrEader.isCameraRunning()) {
qrEader.start();
}
}
sure I'll try that, I did a little hack, but yours is a lot cleaner. Thanks @alexxgarci
Hi guys, I have the same issue and still not solved it, any suggestion ? I try the solution of @alexxgarci but it not work.
Hi,
try to manually add the surface view on the code, and remove on on pause (or whenever) and add it back.
I'll try to create a gist code later and share it here.
On Thu, Sep 28, 2017 at 5:07 PM, datnt1987 [email protected] wrote:
Hi guys, I have the same issue and still not solved it, any suggestion ? I try the solution of @alexxgarci https://github.com/alexxgarci but it not work.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nisrulz/qreader/issues/41#issuecomment-332776355, or mute the thread https://github.com/notifications/unsubscribe-auth/AG9e9FOCMWqg8mdRb8E2YFQRi_FaiySDks5sm2HVgaJpZM4N8FY2 .
Dear @ralphgabrielle , It worked, thanks so much
Glad it helped you. Cheers
On Fri, Sep 29, 2017 at 1:57 PM, datnt1987 [email protected] wrote:
Dear @ralphgabrielle https://github.com/ralphgabrielle , It worked, thanks so much
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nisrulz/qreader/issues/41#issuecomment-333037924, or mute the thread https://github.com/notifications/unsubscribe-auth/AG9e9JhWPSIauEUW7CdoCiU4wohYcFRVks5snIa_gaJpZM4N8FY2 .
this code working for me
@Override protected void onPause() { super.onPause(); qrEader.initAndStart(surfaceView); if(qrEader.isCameraRunning()){ qrEader.stop(); } }
@Override
protected void onResume() {
super.onResume();
qrEader.initAndStart(surfaceView);
if (!qrEader.isCameraRunning()) {
qrEader.start();
}
}