qreader icon indicating copy to clipboard operation
qreader copied to clipboard

Black screen when re opening app

Open ralphgabrielle opened this issue 7 years ago • 8 comments

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

ralphgabrielle avatar Jun 16 '17 06:06 ralphgabrielle

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.

rbuiten avatar Jun 20 '17 13:06 rbuiten

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();
        }
    }

alexxgarci avatar Jul 26 '17 10:07 alexxgarci

sure I'll try that, I did a little hack, but yours is a lot cleaner. Thanks @alexxgarci

ralphgabrielle avatar Jul 27 '17 02:07 ralphgabrielle

Hi guys, I have the same issue and still not solved it, any suggestion ? I try the solution of @alexxgarci but it not work.

datnt1987 avatar Sep 28 '17 09:09 datnt1987

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 .

ralphgabrielle avatar Sep 29 '17 01:09 ralphgabrielle

Dear @ralphgabrielle , It worked, thanks so much

datnt1987 avatar Sep 29 '17 05:09 datnt1987

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 .

ralphgabrielle avatar Oct 03 '17 00:10 ralphgabrielle

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();
    }
}

akashp1992 avatar Jan 01 '20 06:01 akashp1992