Hello,
I am trying to start a Timer from a service module but having some issue in doing it.
In my Main Activity I have the following code:
Sub Process_Globals
Dim connectiontimer As Timer
connectiontimer.Initialize("connectiontimer",3000)
connectiontimer.Enabled = False
End Sub
Sub connectiontimer_tick
Msgbox("test","")
connectiontimer.Enabled = False
End Sub
In my Service module I am activating the Timer by doing the following (this gets activated by a event in the Service Module):
Main.connectiontimer.Enabled = True
Main.connectiontimer.Interval = 3000
However when I run the above code on my device I get a message on my device saying is has stopped and closes.
In the B4A Log it comes up with the following error:
java.lang.NullPointerException
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:104)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:4788)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
Anyone know why this is happening or what I might be doing wrong?