Android Question Url exist or not

parijs

Active Member
Licensed User
Longtime User
Hi, I am looking for code to check if a url still exists so that if it does not exist I will not go there
 

DonManfred

Expert
Licensed User
Longtime User
Try to download the page with okhttputils. If the URL does not exists you´ll get an error.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
other:
Library NetWork
B4X:
' 
    Wait For (Ping("translate.google.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("google.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("b4x.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("b4xxxx.com", 443)) Complete (Result As Boolean)
    Log(Result)
  
    Wait For (Ping("noooooooone.com", 443)) Complete (Result As Boolean)
    Log(Result)

B4X:
Public Sub Ping(Host As String, Port As Int) As ResumableSub
    Dim Socket As Socket
    Try
        Socket.Initialize("Socket")
        Socket.Connect(Host, Port, 60 * DateTime.TicksPerSecond)
        Wait For Socket_Connected (Successful As Boolean)
    Catch
        Log(LastException)
    End Try
    Return Successful
End Sub

1725581231090.png
 
Upvote 0
Top