Loop problem in the QR code scanner screen

Hello! I’ve created a QR code scanner app using the blocks you mentioned. The app consists of three pages:

  1. Splash Screen: The first page serves as the splash screen.
  2. Instructional Page with Camera Start Button: The second page includes an explanatory image of how the app works, along with a button to start the camera.
  3. QR Code Detection Page: The third page, using the barcode scanner sensor, defines the steps for detecting QR codes under specific blocks.

While testing the app in AI Companion, you don’t encounter any issues. However, when testing it on Android devices, the second page (the intermediary interface for displaying scan results) behaves unexpectedly. After pressing the “Enable Camera” button to initiate QR code detection, the page repeatedly opens and prevents the display of results. Sometimes, after several attempts, you can see the results, but it eventually returns to the second page, creating a loop.

To display scan results not as text or etc. but as Image files, I’ve used a WebViewer instead of a text label and text operator due to the QR codes’ ability to display images and other content (Used "qr.io" for image enabled QR Codes)

. It seems that this choice might be causing the looping issue on the second screen but I'm not sure. please help me with this if you can.

Thanks in advance.


Test your barcodescan result in a label, what do you see ?

Do you have useExternalScanner unticked in the designer ?

Opening another Screen when Back is pressed sounds like it would pile up screens in memory.

Normally, apps close screens as often as they open them to avoid that.

Hi. Yes I've unchecked the use ExternalScanner but still the same result. Also checked the text based barcode and labels and that works fine and showed me the barcode text or else.
Problem is I encounter multiple screen loops that opens bt didn't let me to see the results even I've managed to see the results in the new page for a second or two but always opens middle screen and pile up the memory.

Dear ABG. Thanks for your explanation but I didn't understand the necessary action to solve the problem here. Do you suggest to edit the BACK PRESSED sections or simply remove them ? or what. Can you explain further.

Do in Screen4 the same thing you do in Screen3 when Back is pressed (close screen).

Still the same. Same error happens and without getting results in a 2 or 4 seconds gets back to the screen 3 . If I press back one or two times I get the results but for a second then loop begins and If I do or press nothing, again and again opens screen 3 in an infinite loop.
What is the matter I do not get but I assume that there is a problem with either "WebViewer Component" or "Barcode Scanner" Sensor. Maybe I mistyped something but I don't get exactly what to do in this situation.
Please help me with this if you can, I will appreciate it.

When you open/close Screens, there is some timing lag. Have you tried virtual screens?

Hi @SteveJG thanks explaining about Timing lag. I didn't knew about "Virtual Screens" but I Searched about them and learn some step I think. But after removing Screen4 and adding a "virtual screen" in my screen 3. (I have now 2 screens, splash is 1 and second main screen is 3).
I get a warning massage that "Error 1501: Your device does not have a scanning application installed." when testing in AI COMPANION
I know I must've done something wrong in "virtual Screen" part or implementing the 2 buttons in a Screen and etc.. but this is what I came up.
If you help me to solve this even testing will be appreciated alot.

Thanks in advance.

This is my block and designer structure :

this is my main screen in AI COMPANION looks like:

We have to see the full picture ...

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.



Thanks for your help @ABG & @SteveJG .this is my .aia project and all of the files within that.
thank you all very much again for your help.

QRCode_Scanner_copy.aia (214.8 KB)

un-checking UseExternalScanner should eliminate the error.

as a test I added a label to see what has been scanned because I do not scan a QR that points to a URL. The scanner works on my Android 13.

Nice graphics. :wink:

Set WebViewer to 50% height in it's Properties; then scan the attached

QR code and your app points to a url.and displays the page if you scroll after scanning. You need to tidy this up a bit to do exactly what you want. Experiment,

1 Like

Thanks again for your efforts and very helpful guidance Dear @SteveJG .
But with all due respect, Again when I run the app in AI COMPANION (it needs adjustments as you mentioned above in WebViewer) and works fine, but when testing in MY Android 9.0 device or LDPLAYER simulator both gets me the same loop cycle of the same page.

this is the video of running the app in my device and the so called screen reset problem.

problem of the looping still remains even after all the tests.
Main problem is that screen loops back again and always resets itself. I don't know maybe I have some compatibility issues in my device or something else that I do not know yet but I still want to try different methods cause I want to solve this somehow, In the meantime I will be appreciate if you have any suggestions or any kind of help or etc..

I notice in Screen1 you don't turn off the Clock before opening Screen3.

That can cause problems.
Screen1 blocks

P.S. I can't vouch for anything with extensions in it. Ask the author, in the place you got them.

1 Like

I also notice in Screen3 the Arrangements are empty.
(No indentation, so they don't hide anything but themselves.)

If all your components are set to Automatic, they will fight for screen real estate at run time depending on what's in them.

What were you expecting Button2 to do for you?

I see your Sizing is Responsive, a useful default.

However in Screen3 Button2 gets 90 pixels vertically, which might be a different portion of the screen on devices with different resolutions.

For tighter control of appearances, use per centages for Responsive Design.

P.S.. You use a lot of fancy effects.
I don't do fancy.

@ABG thanks about the "clock on/off" and extension topic.
I will use a static picture as splash.
but for button 2 , I did not know that I used a correct block structure and shared it with you for guidance and correction if necessary.

After these things that you informed me, I want to remove the "virtual screen" part and rebuild the whole screens without the extension or else and try to open the result of the scanning processes in another screen to check the results.

For button2, the blocks are okay, but the Designer structure is not okay.

Arrangements are meant to act as containers for other components, so they can all be made visible or not as a group.

Perhaps you missed the lesson where the mock components can be dragged around in and out of arrangements?

P.S. An example of Arrangements usage:

Dear @ABG I'm so grateful for your time and effort in helping me with this. Thank you very much. I will read the example and try the instructions above :pray:

Switching Screens is more disruptive than hiding content in a single screen, especially for a small app like this.

You can rename the enclosing Arrangements and components to help you (and hopefully us English readers) identify what each component is and its purpose (like ButtonScan)

1 Like