Android Question Sleep not resumed (context is paused)

FERNANDO SILVEIRA

Active Member
Licensed User
Hello guys,

Basically the program is a never ending loop, moving squares on the canvas.

I'm getting this message when pausing (switching apps) while my program is running.
It also happens when the display turns off by inactivity.

What should I do to resume my program after a pause?

Regards,
Fernando
PS: below is a simplified program flow. Attached is the project ZIP


Main Module

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    draw.Initialize(Activity)
   
End Sub

Sub Activity_Resume

End Sub

Drawings Module
B4X:
Public Sub Initialize(Parent As B4XView)
    ProcessGame
End Sub

Sub ProcessGame
    PlotBird
    PlotSnake
    Do While True
        Sleep(10)
        MoveSnake
        Log("SnakeCell " & SnakeCell)
    Loop
End Sub
 

Attachments

MarkusR

Well-Known Member
Licensed User
would a timer tick event replacing your endless loop?

instead of
B4X:
Do While True
you can also insert a boolean variable to end this loop. (i not looked into your project)
 

FERNANDO SILVEIRA

Active Member
Licensed User
I'm not sure the SLEEP() is causing the issue, 'cause it happens even if I comment the sleep() command.

This error happens whenever I click home button on the cell phone to use another app and then, when I (try) return to my app it is stopped already.
 

MarkusR

Well-Known Member
Licensed User
first i need sleep / resume myself ;)
 
Top