Android Question Run A Service In The Background

SpinBower

Member
Licensed User
Longtime User
Hi, i've finished the login part and I need to have a service running that repeatedly checks a file. What I have so far just gives an error and kills the app. Can someone tell me why?

B4X:
'So The App Checks Something Then Runs This

StartService(CheckSettings)

'Here is the service file

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
Dim Name As String
Dim ListData As List
Public manager As AdminManager
Dim FTP As FTP
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
CheckLostMode
End Sub

Sub Service_Destroy

End Sub

Sub CheckLostMode
If FTP.IsInitialized = False Then
FTP.PassiveMode = True
FTP.Initialize("FTP", "***********", 21, "******", "******")
End If
ListData = File.ReadList(File.DirInternal, "userdata.txt")
Name = ListData.Get(0)
Msgbox(Name, "")
FTP.PassiveMode = True
FTP.DownloadFile(Name & ".txt" , False, File.DirInternal, "userdata.txt")
End Sub
 

HotShoe

Well-Known Member
Licensed User
Longtime User
You are setting passive mode before the ftp object is initialized.

--- Jem
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
What is the error given, and where does it occur?
 
Upvote 0

SpinBower

Member
Licensed User
Longtime User
So when I don't run the service, the error does not occur so that means it in the service code. It dosent even have time to return an error it just says: "LostMode has stopped." Then Closes
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…