Android Question Internet Job complete

Peekay

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

Globals:
    Private InterNetJob As HttpJob
    Private InternetAccess As Boolean

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

And this sub:
Sub:
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
 

DonManfred

Expert
Licensed User
Longtime User
Are you using wait for? If so then you should not have a JobDone sub at all.
 
Upvote 0

Peekay

Active Member
Licensed User
Longtime User
Thanks DonManfred.

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

With this sub:
Sub:
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

Peekay

Active Member
Licensed User
Longtime User
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
Top