The app is designed to link to a DropBox account using DropBox Sync Lib. It creates a text file from a SQLite table and uploads the text file to DropBox. The service allows it to repeat creating the text file and the upload every 3 minutes (eventually every few hours).
9:00 AM FIRST RUN: Compile run. Authenticate account, create text file and upload OK.
9:03 AM SECOND RUN: Create file and upload to Dropbox OK. But error shows: Program paused on line 64 which is the End Sub line of the Service_Start sub
9:06: AM THIRD RUN: Text file is created, but no more upload to Dropbox.
Can someone help me sort this out so it works on a scheduled basis and no ghost activity is displayed when the upload is finished.
Thank you
9:00 AM FIRST RUN: Compile run. Authenticate account, create text file and upload OK.
9:03 AM SECOND RUN: Create file and upload to Dropbox OK. But error shows: Program paused on line 64 which is the End Sub line of the Service_Start sub
9:06: AM THIRD RUN: Text file is created, but no more upload to Dropbox.
Can someone help me sort this out so it works on a scheduled basis and no ghost activity is displayed when the upload is finished.
Thank you
B4X:
'BELOW ACTIVITY MODULE
Sub Process_Globals
Dim Manager As DbxAccountManager
Dim keyDBX As String = "bjeokwhf0fy5xudl"
Dim secretDBX As String = "p094farez7t00"
Dim SQL1 As SQL
Dim Cursor1 As Cursor
End Sub
Sub Globals
'pertinent variables declared here.
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Manager.Initialize(keyDBX, secretDBX, "Manager")
Manager.LinkAccount
End If
'Here initialize database code
CreateDailyTextFile 'sub to create text file from a SQLite table. WORKS OK
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed AsBoolean)
End Sub
Sub CreateDailyTextFile
'Here I have code that creates the text file from a SQLite table
End Sub
Sub Manager_AccountReady (Success As Boolean)
Log("Account Ready: " & Success)
If Success=True Then
MySuccess=Success
Log("Success: " & MySuccess)
UpLoadFile
Activity.Finish
StartService(svcDownload)
End If
End Sub
Sub UpLoadFile
Manager.UpLoadFile(DBFilePath,MyDailyTextFile,"/Import",MyDailyTextFile)
Log("Text file " & MyDailyTextFile & " was uploaded successfully")
End Sub
B4X:
'BELOW IS FULL SERVICE MODULE CODE:
#Region Service Attributes
#StartAtBoot: True
#End Region
Sub Process_Globals
Dim sNotify As Notification
End Sub
Sub Service_Create
sNotify.Initialize
sNotify.Icon = "icon"
sNotify.SetInfo("HHE","Auto Export Daily Files to DropBox",Main)
sNotify.Sound = True
sNotify.Notify(1)
Service.StartForeground(1,sNotify)
End Sub
Sub Service_Start (StartingIntent AsIntent)
Dim p As Period
p.Minutes = 3 'minutes . In future, I will change to hours
Dim NextSchedule As Long = DateUtils.AddPeriod(DateTime.Now, p)
StartServiceAt("",NextSchedule,True)
StartActivity(Main)
End Sub 'PROGRAM PAUSED ERROR HERE