Hi,
When the user activity_pause the app, I want to send through job.postSting this information to a remote server.
I notice that, because the app is paused, the job is sent to the waiting queue ...
I found here that to avoid this, it's best to start a service.
Hereunder is how I do ...
Is it the correct way ?
somewhere in the 'main' module of the app :
in the 'service' module of the app :
BTW,
Should I add in the 'main' module an :
activity.Finish (if I want the app just no be just paused but definitly terminated)
?
Thanks in advance for yours remarks and comment

When the user activity_pause the app, I want to send through job.postSting this information to a remote server.
I notice that, because the app is paused, the job is sent to the waiting queue ...
I found here that to avoid this, it's best to start a service.
Hereunder is how I do ...
Is it the correct way ?
somewhere in the 'main' module of the app :
B4X:
sub activity_pause()
callsubdelayed("service","send2Server")
end Sub
in the 'service' module of the app :
B4X:
Sub Process_Globals
Dim endJob As HttpJob
End Sub
Sub Service_Destroy
Log("Entering service_Destroy")
End Sub
Sub send2Server()
Log("Entering send2Server ....")
endJob.Initialize("jobEnd",Me)
endJob.PostString("http://myurl","mypayload")
End Sub
Sub jobDone(job As HttpJob)
Log("Entering service-jobDone")
If (job.Success) Then
Service_Destroy
Else
Log("Error on "&job.JobName)
End If
End Sub
BTW,
Should I add in the 'main' module an :
activity.Finish (if I want the app just no be just paused but definitly terminated)
?
Thanks in advance for yours remarks and comment