Android Question Problem. Activity Start from wrong place


Active Member
Licensed User
I have a function like this, my app connect to an internal API, but the is protected by VPN then is not avalaible on everytime.

My problem come from there, if the user try to download data from API but don't have VPN connected or no internet the httpJob persist on background, the user continue working on other activities.

But when the httpjob release by timeout, the activty source of the request bring to the front.
If the user touch the button download 10 times, are 10 timeouts, 10 bring to the front.
The app not crash and not blocked, but is no very nice for the user, if you are making something and bring other activities without any aparent reason.

I have 1 layout per activity, something like this:

Activity = act_report
Layout = frm_report

Sub func_downloadsomething
    Dim Servidor As String
    Dim Puerto As String
    Servidor = ""
    Puerto = "8888"
    Dim j As HttpJob
    j.Initialize("", Me)
    Log("Conexiión a Equipo remoto")
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        'Download something
        Dim parser As JSONParser
        Dim root As List = parser.NextArray
        For Each colroot As Map In root
            HOUR_START = colroot.Get("HOUR_START")
            ID = colroot.Get("ID")
            DATE1 = colroot.Get("DATE1")
            lista.AddTwoLines(ID, "Fecha: "&DATE1.SubString2(0, 10)&" Hora: "&HOUR_START)
    End If
End Sub