Android Question Httpjob's timeout

Facilauto Juan

Member
Licensed User
Longtime User
Hello there!

I'm using httpjob to download google from internet and check that way if I have a working internet connection.

The problem is that I need to set the httpjob's timeout to 1 second. Now I'm getting 5 to 10 seconds where my app can't determine if there is internet or not because its waiting for the httpjob response.

Is there a way to set this? Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
dim p as Phone
Dim sb As StringBuilder
p.Shell("ping -c 1 www.google.com",Null,sb,Null)
Log(sb)
 
Upvote 0

baron

Member
Licensed User
Longtime User
I get a java null pointer exception when I use the timeout parameter as follows - what am I doing wrong ?

Dim httpPayment As HttpJob

httpPayment.Initialize("httpPayment", Me)
httpPayment.GetRequest.Timeout = 60000
httpPayment.Download2("https://abc.com/xyz.asp",aString)

It works fine if I comment out the GetRequest.Timeout line !
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
I get a java null pointer exception when I use the timeout parameter as follows - what am I doing wrong ?

Dim httpPayment As HttpJob

httpPayment.Initialize("httpPayment", Me)
httpPayment.GetRequest.Timeout = 60000
httpPayment.Download2("https://abc.com/xyz.asp",aString)

It works fine if I comment out the GetRequest.Timeout line !

I think you have to put the GetRequest after the Download2
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
The best way to check to see if you have an internet connection is to do the following.

Check/Tick Network library.

B4X:
Dim Server As ServerSocket
Server.Initialize(0, "")

If Server.GetMyIP = "127.0.0.1" Then
  'You have no internet, re-run again using timer or something.
Else
  'You have internet
End if
 
Upvote 0
Top