As a full-time hobby programmer I like challenges and I love B4X because there is never a dull moment and it is always full of surprises.
E.g. Using Erel's DownloadAndSave routine (which I have before successfully used for years) now throws this error:
ResponseError. Reason: java.net.ConnectException: Failed to connect to www.bizgraphic.ch/192.168.0.118:443, Response:
Maybe 192.168 has something to do with my Wlan settings, the firewall or the VPN I am using or even with Windows 11?
Why and what can be done do correct it?
here is the code
Can anybody help this poor guy?
Thank you in advance,
john m.
E.g. Using Erel's DownloadAndSave routine (which I have before successfully used for years) now throws this error:
ResponseError. Reason: java.net.ConnectException: Failed to connect to www.bizgraphic.ch/192.168.0.118:443, Response:
Maybe 192.168 has something to do with my Wlan settings, the firewall or the VPN I am using or even with Windows 11?
Why and what can be done do correct it?
here is the code
download and save a file:
Dim URL As String = "https://www.bizgraphic.ch/elxf/elxf-specification.pdf" 'V/downloads/help33_en.vlst"$
Dim A As String = URL.SubString(URL.lastindexof("/")+1)
Wait for (Starter.DownloadAndSave(URL, Starter.downloadPath, A)) Complete (Success As Boolean)
If Success Then
Log("Download completed")
Else
Log("file not found")
End If
Public Sub DownloadAndSave (Url As String, Dir As String, FileName As String) As ResumableSub
Log("Download URL="&Url&", Dir="&Dir&", File="&FileName)
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Url)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) 'TargetFolder, Filename, Append true/false
File.Copy2(j.GetInputStream, out)
out.Close
End If
j.Release
Return j.Success
End Sub
Manifest editor:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddPermission(android.permission.MANAGE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_EXTERNAL_STORAGE)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
Can anybody help this poor guy?
Thank you in advance,
john m.