I use a service to download 6 text files from Dropbox to my tablet using Erel’s Dropbox lib 1.25 and Dropbox API Sync lib 2.0. The files are uploaded manually from my PC to Dropbox server. The files range from 1KB to 300 KB each. The file names are always the same, but the sizes change. The service runs every 3 minutes for the sake of this test. I only get the new files every other service run. It seems like it is not syncing with the new files in Dropbox server. When I check Dropbox server, the new files always appear almost immediately after I upload the 6 files to it from my PC. Could you please find my problem in the attached code and project. I did not include the files because they are simply any text files.
Thank you
'BELOW SERVICE CODE:
'BELOW ACTIVITY MOST IMPORTANT CODE:
Thank you
'BELOW SERVICE CODE:
B4X:
Sub Process_Globals
Dim sNotify As Notification
End Sub
Sub Service_Create
sNotify.Initialize
sNotify.Icon = "icon"
sNotify.SetInfo("HHE","Auto Download DropBox Files",Main)
sNotify.Sound = True
sNotify.Notify(1)
Service.StartForeground(1,sNotify)
End Sub
Sub Service_Start (StartingIntent As Intent)
StartActivity(Main)
End Sub
'BELOW ACTIVITY MOST IMPORTANT CODE:
B4X:
If FirstTime Then
Manager.Initialize(keyDBX, secretDBX, "Manager")
Manager.LinkAccount 'must link to account
End If
Manager.AutoSync =True 'per new Erel lib 1.25
DBFilePath = File.DirRootExternal & "/HHE" 'subfolder called HHE
TenderID="DG1"
MyListtwo.Initialize
End Sub
Sub Activity_Resume
Manager.LinkAccount
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Manager_AccountReady (Success As Boolean)
MyListtwo.Initialize
Log("Account Ready: " & Success)
If Success =True Then
'Export is a Dropbox subfolder where all 6 files are downloaded from Dropbox
'The 6 files are all text files ranging from 1 kB to 300 KB max each.
'The 6 File names: DG1_Base_Comments.tab, DG1_Base_Consumables.tab, DG1_Base_Settings.tab,
'DG1_Base_Goals.tab, DG1_Base_Wells.tab, DG1_Daily.csv
For Each FileInfo As DbxFileInfo In Manager.ListFiles("/Export")
If FileInfo.Name.StartsWith(TenderID) OR FileInfo.Name.StartsWith("Base_") Then
MyFile=FileInfo.Name
MyListtwo.Add(MyFile)
End If
Next
End If
If Success=True Then
CallSub(Me,"Download") 'start downloadt
Dim p As Period 'for testing service run every few minutes
p.Minutes = 3
Dim NextSchedule As Long = DateUtils.AddPeriod(DateTime.Now, p)
StartServiceAt(svcDownload,NextSchedule,True)
Activity.Finish
End If
End Sub
Sub Manager_DownloadCompleted (Success As Boolean, LocalDir As String, LocalFileName As String)
Log("Download Completed: " & Success)
End Sub
Sub Download
For i=0 To MyListtwo.Size-1
MyFile=MyListtwo.Get(i)
GetFile
Next
End Sub
Sub GetFile
Manager.DownloadFile("/Export", MyFile, DBFilePath, MyFile)
Log(MyFile)
ToastMessageShow(MyFile,False)
End Sub