Android Question Use Wait for JobeDone for check net

devmobile

Active Member
Licensed User
Hi
I use Waiting For JobDone for check internet status
Acctually i download file and if jobdone is successfully so intertnet is active and not downloaded so internet is disactive
And set timeout for download
Is it good way for check internet?
 

DonManfred

Expert
Licensed User
Longtime User
I can download file with java code inline b4a without use JobDone
with okhttputils and using wait for you can download a file too. without using JobDone ,
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
To avoid repeating the code you can create this sub:
B4X:
Sub IsInternetAvailable As HttpJob
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Download("https://www.google.com") 'or better your own link
   Return j
End Sub

Now you can write wherever you want to check:
B4X:
Wait For (IsInternetAvailable) JobDone(j As HttpJob)
If j.Success Then
   'internet is available
End If
j.Release
 
Upvote 0

devmobile

Active Member
Licensed User
To avoid repeating the code you can create this sub:
B4X:
Sub IsInternetAvailable As HttpJob
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Download("https://www.google.com") 'or better your own link
   Return j
End Sub

Now you can write wherever you want to check:
B4X:
Wait For (IsInternetAvailable) JobDone(j As HttpJob)
If j.Success Then
   'internet is available
End If
j.Release
OK
 
Upvote 0
Top