Android Question Service and Timer - which module to put subs in?

Scotter

Active Member
Licensed User
I'm just learning how to use timer and service.
My app has "main" and "service" modules.

I moved the following to service (leaving out default subs I put nothing in):
SERVICE MODULE
B4X:
Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: False
#End Region
Sub Process_Globals
    Dim RotateTimer As Timer
End Sub
Sub Service_Create
    'This is the program entry point.
    'This is a good place to load resources that are not specific to a single activity.
    RotateTimer.Initialize("SDTime", 1500)  '1000 Milliseconds = 1 second
    RotateTimer.Enabled = True
End Sub

MAIN MODULE
B4X:
Sub SDTime_tick
  ImgBanner.Bitmap=LoadBitmap(File.DirAssets,ListPictureIds.Get(iCurrentBanner) & ".jpg")
  iCurrentBanner=iCurrentBanner+1
  If (iCurrentBanner>ListPictureIds.Size-1) Then iCurrentBanner=0
End Sub

When debugging, it just crashes with no error in log.
 
Top