Android Question Internet Job complete

Peekay

Active Member
Licensed User
Longtime User
I have this in Globals:

Code: Copy
    Private InterNetJob As HttpJob
    Private InternetAccess As Boolean

And this in Main Activity_Create:
Code: Copy
    InterNetJob.Initialize("Job1", Me)
    InterNetJob.Download("http://www.google.com")

And this sub:
Code: Copy
Sub JobDone(Job As HttpJob)
    If Job.JobName="Job1" And InterNetJob.Success=False Then
        InternetAccess = False
    Else
        InternetAccess = True
    End If
    Job.Release
End Sub

The problem is that it does not go through the sub.

Thanks
PK
 
Are you using wait for? If so then you should not have a JobDone sub at all.
 
Upvote 0
Thanks DonManfred.

I tried this as well, which did not work:
Code: Copy
    Dim xrs As ResumableSub = TestInternet
    Wait for (xrs) Complete(InternetAccess As Boolean)
    Log("there is internet: " & InternetAccess)

With this sub:
Code: Copy
private Sub TestInternet As ResumableSub
    Dim InterNetJob As HttpJob
    InterNetJob.Initialize("",Me)
    InterNetJob.Download("https://www.google.com")
    Wait For (InterNetJob) JobDone(Job As HttpJob)
    Return InterNetJob.Success
End Sub

I am not sure when I should use what.
OK
 
Upvote 0
I played with DonManfred's advice and used wait until I got it right. He is right - if you use wait, you do not have to have a sub for a job.

PK
 
Upvote 0
Back
Top