Android Question ToastMessage not all appearing

rworner

Member
Licensed User
Longtime User
I want to display a toast message while searching for the ethernet connection. Then after a 3 seconds display a second toast message - either connection found or no connection. Instead of that occurring it appears to skip the first toast message.
 

Attachments

  • testconnection.zip
    6.9 KB · Views: 185
Last edited:

Eric H

Active Member
Licensed User
Longtime User
can you please edit your post and re-paste your code inside code tags? It is much easier to try and help you when the code is easier to follow. I would recommend re-copying it from your IDE code window so you preserve the indents as well. you can either use the code button on the forum formatting toolbar, or you can use the standard [ CODE][ /CODE] tags (remove spaces).
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
This is a bad way to create a pause in Android:
B4X:
'delay to give device time to setup connection
s = DateTime.now
Do While DateTime.now < s+3000
Loop
You should be using a TIMER, however, if you want to use that "bad" code add a DoEvents inside the Loop.
 
Upvote 0

rworner

Member
Licensed User
Longtime User
If I changed it to a timer would I need to put all of the code below that point into the timer so that it would not execute until the timer was activated? (Still trying to figure out how all of this works compared to linear programming...)
 
Upvote 0

rworner

Member
Licensed User
Longtime User
Yes, you will do what you need in the timer's TICK event.

And please use the [code] ... [/code] tags or attach your project.
How do I do that? I just copied and pasted from the IDE.
Look at the attached sample.
Thanks for the assistance. My coding so far is designed to see if my understanding of B4A works as I expect. I do small sections separately to make sure they work then piece them all together. A hold over from my "modular" programming days. The concept I am not grasping in this example is why did the first Toast message: ToastMessageShow("Searching for Ethernet Connection...", True) not appear on the screen, but it proceeded to the Toast message located in the later IF statement and displayed the correct message based on if the ethernet connection was connected or not.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
How do I do that? I just copied and pasted from the IDE.
You HAVE to type those tags BEFORE pasting your code.
The concept I am not grasping in this example is why did the first Toast message: ToastMessageShow("Searching for Ethernet Connection...", True) not appear on the screen
The reason is due to the way you were creating that "pause", that prevents the main thread to update the UI, as I explained before, that's a bad way to program in Android.
 
Upvote 0
Top