Problem with long list loop processed list

I send over 2000 Bytes via bluetooth. I use “for each item in list” for this. Sending these bytes takes about 3 minutes. During this time, the application displays an error 3 times that the window is not responding. I can click “End Application” or “Wait”. I click “Wait”, sending goes on and is successful. Can I get rid of the message that the application is not responding?

1 Like

use a clock component rather than a long list loop
see The 'Do something' example
see also The model of event processing in App Inventor by Lyn


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

I know, I can work around the problem with the clock. I’m just surprised that the correct procedure is being carried out and the application is reporting an error. I don’t want to do anything while sending, and I get the “show progress dialog” notification. App inventor has many limitations. I will use the clock.

There are 2 alternatives to try;

Build a 2000 byte message from the list using the
join with separator list block and send that long message, or

Have the receiving device acknowledge receipt of each item
before sending the next item. Use a temporary list and send item 1,
remove item 1 after receiving acknowledgement of receipt.

The device confirms each byte by sending back the same byte. I have loops for “for each item in list”. I process a list in which each item is 1 byte to send. In this loop I have a second “while” loop that receives confirmation. If confirmation is missing within 2000 cycles, the loop is interrupted and displays a communication error. If confirmation is received, the loop is interrupted and another byte from the list is sent. It works fine. Only during work loops the list the application displays an error that the screen is not responding.

Loops are the problem here.
Use a fast clock to poll for input and depletable queues.

If you post an .aia I can show you more.

There is a Waiting and Timing section of FAQ
with essays on this.

My guess is that because the loop from the list is long the system thinks that the application has crashed. It surprised me why I wrote. So that’s how android works? Is the list loop not suitable for very long lists? I’ll do it with a clock and add progress display in%. It is a pity that there is no extension with progress in the popup. Will the clock actions be as fast as in the loop? Will it slow down communications even more?

Welcome to the world of interactive devices.
Their operating systems resent processes that go into comas without
occasionally coming up for air to let the rest of the O/S attend to business.

Try coding a Sieve of Eratosthenes prime number generator without a
Clock to work in batches, for confirmation.

App Inventor is single threaded... so everything runs in the UI thread...
see again The model of event processing in App Inventor by @Franklyn_A_Turbak

but you could try the following extension and run your loop in another thread...
Async Procedure Extension by Abhijith Dominic, source code by @ewpatton (MIT)
let us know, how this works for you...


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

(added to Waiting and Timing section of FAQ)

I will try this extension soon, thanks.

It’s works, but displays error 3300 at the end of the procedure.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

The procedure works correctly. Finally, after sending all bytes, it receives an E0 response. After receiving E0, it should display a message saying that sending was successful. Unfortunately, it does not display this message and shows error 3300 instead. I don’t know, maybe this extension is not working well with notification?

Nothing is done after this procedure. Progress notification is turned off correctly, the last two bytes FF sent also correctly and bluetooth off. Only success notification is not displayed.

this might be...
what about displaying your message in a label as workaround?

The extension has an event. I will try to use the event “CallFinishedWithResults” and make a notification in it. Unless this event is just for the procedure with the result?

According to
error 3300 originates in an extension, so you are probably looking in the right place.

It works like this:

2kB sends in over 2 minutes. Bluetooth is so slow?

1 Like