My Knowledge of ‘Service’ module is virtually non-existent, but I read just about every post that has the word 'service'. The app starts, links to a DropBox account, which it does and then download 6 files ranging from 1 KB to 3 MB from DropBox server, which it does. Here are my problems:
1. It only downloads twice: the first time after compile and the next time.. It does not repeat although I schedule every 3 minutes (later I plan to change it a bigger time interval such as 1 day). When the 3rd and 4th shedules run, the log says: ‘Service (name of service) Start’, but no download happens.
2. I want the app to work in the background. I only want to show the toast messages.
If you have a good grasp of service I need your help
'Download sub is in service module svcDownload
1. It only downloads twice: the first time after compile and the next time.. It does not repeat although I schedule every 3 minutes (later I plan to change it a bigger time interval such as 1 day). When the 3rd and 4th shedules run, the log says: ‘Service (name of service) Start’, but no download happens.
2. I want the app to work in the background. I only want to show the toast messages.
If you have a good grasp of service I need your help
B4X:
'In Activity module. Full code.
Sub Activity_Create(FirstTime As Boolean)
StartService(svcDownload)
Activity.Finish
End Sub
'In Service module
#StartAtBoot: false
Sub Process_Globals
Dim Manager As DbxAccountManager
Dim keyDBX As String = "xxxxrspn1tlyyy”
Dim secretDBX As String = "wwww08ckvvvvv"
End Sub
Service_Create
Manager.Initialize(keyDBX, secretDBX, "Manager")
Manager.LinkAccount 'must link to account
Manager.AutoSync =True '
Mytimer.Initialize("MyTimer",1000) 'timer allows accnt to link before download
t1=DateTime.Now
Mytimer.Enabled=True
End sub
Sub Service_Start (StartingIntent AsIntent) 'repeat download every 3 minutes
Dim p As Period
p.Minutes = 3
Dim NextSchedule As Long = DateUtils.AddPeriod(DateTime.Now, p)
StartServiceAt(svcDownload, NextSchedule,True)
End Sub
Sub MyTimer_Tick
Dim t2 AsLong
t2=DateTime.Now
If t2-t1 >=5000 Then 'wait 5 sec
Mytimer.enabled=False
CallSubDelayed("","Download") 'this is the download routine sub
End If
End Sub
Last edited: