I found CancelDownload in DownloadService module,Can you move it to HttpUtils2 module?
B4X:
Public Sub CancelDownload(url As String)
If jobs.ContainsKey(url) = False Then
Log("Ignoring cancel request.")
Return
End If
Dim job As HttpJob = jobs.Get(url)
Dim jt As JobTag = job.Tag
If jt.CountingStream.IsInitialized Then
jt.CountingStream.Close
Else
jt.Data.url = ""
End If
End Sub
I send URL run long time and exit current activity, this httpjob not over,So I want cancel it.
DownloadService is based on HttpUtils2. You can use it as is or you can follow the same approach which is to close the output stream. Note that you must use the latest version of Http library for this to work properly.
Sub CancelJob(url As String)
If TaskIdToJob.ContainsKey(url)=False Then
Log("Ignoring cancel request.")
Return
End If
Dim job As HttpJob=TaskidTojob.Get(url)
Dim jt As JobTag=job.Tag
If jt.CountingStream.IsInitialized Then
jt.CountingStream.Close
Else
jt.Data.url=""
End If
End Sub
I write code for cancel job.
help me , Is it right?