Hello,
i would like to proove if there is an Internet Connection. I am doing that at the Moment with a code that prooves the ping to 8.8.8.8. But i noticed that there are Smartphones like the Samsung S3 which doesn`t allow that test. Are there any other possibilities except the attempt to download a file? with HTTPJob
My code:
And i have try This code
But this error comes:
i would like to proove if there is an Internet Connection. I am doing that at the Moment with a code that prooves the ping to 8.8.8.8. But i noticed that there are Smartphones like the Samsung S3 which doesn`t allow that test. Are there any other possibilities except the attempt to download a file? with HTTPJob
My code:
B4X:
Dim ph As Phone
Dim Response, Error As StringBuilder
Response.Initialize
Error.Initialize
ph.Shell("ping -c 1 8.8.8.8",Null,Response,Error)
If Error.ToString="" Then
Return True
Else
Return False
End If
And i have try This code
B4X:
#If JAVA
public boolean isInternetAvailable() {
try {
java.net.InetAddress ipAddr = java.net.InetAddress.getByName("google.com");
if (ipAddr.equals("")) {
return false;
} else {
return true;
}
} catch (Exception e) {
return false;
}
}
#End If
Sub pruefeInternet As Boolean
Return jo.RunMethod("isInternetAvailable",Null)
End Sub
But this error comes:
B4X:
Sub_main_pruefeinternet....
java.lang.RuntimeException: Method: isInternetAvailable not found in: android.widget.TextView