Android Question How to use timer in project?

gacar

Active Member
Timer cannot tick.

B4XMainPAge :

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private Timer1 As Timer
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Log("AppStart")
    Timer1.Initialize("Timer1_Tick", 1000)
    Timer1.Enabled = True 'don't forget to enable it
End Sub

Private Sub Timer1_Tick
    Log(Timer1.Interval)
End Sub
 
Solution
Timer1.Initialize("Timer1_Tick", 1000) should be Timer1.Initialize("Timer1", 1000)
as written it will call a sub called Timer1_Tick_Tick
Top