Android Question Timer - Sub Process_Globals

JohnD

Active Member
Licensed User
Longtime User
Why do I need to declare a Timer in Sub Process_Globals?

When I declare a timer as below in Sub Process_Globals I get the Null pointer error below

code:

B4X:
Dim Timer1 As Timer
Timer1.Initialize("Timer1",1000)   
Timer1.Enabled = True

error:

java.lang.NullPointerException
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:104)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5455)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)

This only happens when I try to use a Timer in an activity other than Main. No problem in my initial test version in main. When I declare the Timer in Sub Globals no apparent problem other than a Warning in the debugger. Your help would be appreciated.
 
Top