Android Question break jobdone

Hello, everyone
I want to know if there is a way to break jobdone from another function. At my jobdone the waiting panel is called (just download process) and there is a button when I click on which I need to stop executing jobdone, can this be done?)
I use HttpJob
I hope I made myself clear, sorry for my english
 
It is possible to cancel ongoing requests with RequestsManager class from the Pleroma project.

In most cases, these questions come with apps with multiple activities. The correct solution is to switch to B4XPages.

thanks for the answer, Erel

I am getting an error at this point
B4X:
Public Sub CancelRequest (URL As String, Job As HttpJob)
    If HttpUtils2Service.hc.IsInitialized = False Then Return
#if B4J or B4A
    Dim Jo As JavaObject = HttpUtils2Service.hc
    Dim OkHttpClient As JavaObject = Jo.GetField("client")
    Dim RunningCalls As List = OkHttpClient.RunMethodJO("dispatcher", Null).RunMethod("runningCalls", Null)
    For Each call As JavaObject In RunningCalls
        Dim req As JavaObject = call.RunMethod("request", Null)
        Dim s As String = req.RunMethod("url", Null)
        If s = URL Then
            call.RunMethod("cancel", Null)
            Return
        End If
    Next
    For Each j As HttpJob In HttpUtils2Service.TaskIdToJob.Values
        If j = Job Then
            If j.Out.IsInitialized Then j.Out.Close
            Return
        End If
    Next
#else if B4i
    Dim no As NativeObject = HttpUtils2Service.hc
    Dim session As NativeObject = no.GetField("session")
    no = Me
    no.RunMethod("cancelDownload::", Array(session, Job.req))
#end if
    
End Sub

RequestsManager - 25: Unknown member: out
RequestsManager - 23: Unknown member: taskidtojob
RequestsManager - 12: Unknown member: hc
RequestsManager - 10: Unknown member: hc
 
Upvote 0
Top