Android Question sleep ? goto line or goto label ?


Active Member
Licensed User

is their is any library or way to do sleep in b4a without timer ?

the problem with timer is that it must continue to a different sub or it will repeat the sub the the beginning.

in java for example their is a sleep function is their is something like this for b4a ?

or is their is a go to label or go to line feature in b4a ?


Active Member
Licensed User
Although 'goto' is a reserved word in Java, it is not actually supported. See my posts at for more details on this (and why it is not in B4A.

As for 'sleep', depends what you want to do. If you just want the app to pause for a certain length of time, you can use something like:
Sub WaitFor(Milliseconds As Int)
    Dim Present As Long
    Present = DateTime.Now
    Do While DateTime.Now < Present + Milliseconds
End Sub
and call the sub for whatever period you want to program to sleep.


Well-Known Member
Licensed User
Be wary about using such routines as it will hammer the processor and consume battery power. It is better to use a timer wherever possible and stick with the event driven way of working. Maybe you could use a Select Case statement within the timed event to act as a GoTo type of function calling whichever sub you require?