Android Question Wait For (j) JobDone(j As HttpJob) - lost internet connection - app turn off

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends, please for advice,

I have this code:
B4X:
    j.Initialize("", Me)
    j.Download("http://something.com/something.php")
    Wait For (j) JobDone(j As HttpJob)

but sometimes I lost internet connection and then I get this error (my app crashed):
java.io.FileNotFoundException: /data/user/0/my.app.mobile/cache/18: open failed: ENOENT (No such file or directory)

please how can I edit my code?

Best regards
p4ppc
 

DonManfred

Expert
Licensed User
Longtime User
Not enough information to help.

Upload a small project showing the problem.

At least post a full code to replicate the problem.

I don´t see the DIM in your code
I even don´t see a job.Release

Usually reusing the same object is a mistake.

B4X:
dim j as httpjob
j.Initialize("", Me)
    j.Download("http://something.com/something.php")
    Wait For (j) JobDone(j As HttpJob)
    if j.Success then
        dim res as String = j.GetString
        j.Release
    else
        log("Error")
        j.Release
    end if
 
Upvote 1

aeric

Expert
Licensed User
Longtime User
B4X:
Try
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download("http://something.com/something.php")
    Wait For (j) JobDone (j As HttpJob)
    If j.Success Then
        Dim res As String = j.GetString
        Log(res)
    Else
        Log(j.ErrorMessage)
    End If
    j.Release
Catch
    Log(LastException)
End Try
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends,

thank you very much for your help. It was my dumb mistake.

Mistake was in:
B4X:
Dim checkstring As String=j.GetString
but must be:
B4X:
If j.Success=True Then checkstring=j.GetString

Thanks for help from all of you,
best regards
p4ppc
 
Upvote 0
Top