Why Timer NOT work?
B4X:
#Region Project Attributes
#ApplicationLabel: B4A TimerExample
#VersionCode: 1
#VersionName: 0.1
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#BridgeLogger: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Timer1 As Timer
Dim iStejem As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout1")
If FirstTime Then
Log("Set timer.....")
Timer1.Initialize("Timer1_Tick", 2000)
Timer1.Enabled=True
If Timer1.IsInitialized Then Log("Timer1 is INIT OK") Else Log("Timer1 is NOT init OK")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Timer1_Tick
Log("iStejem=" & iStejem)
iStejem=iStejem + 1
Timer1.Enabled=False
Timer1.Interval=2000
Timer1.Enabled=True
End Sub
Logger connected to: samsung SM-N910C
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Set timer.....
Timer1 is INIT OK
** Activity (main) Resume **
java.lang.Exception: Sub timer1_tick_tick was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Set timer.....
Timer1 is INIT OK
** Activity (main) Resume **