Android Question Why is my URL truncated


Active Member
Licensed User
Longtime User
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: Failed to connect to, 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 = "" '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")
                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)
    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)
    End If
    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:
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
SetApplicationAttribute(android:requestLegacyExternalStorage, true)

Can anybody help this poor guy?
Thank you in advance,
john m.


Licensed User
Longtime User
your code, as posted, works fine here. not sure what the problem is.
log output:
** Activity (main) Create (first time) **
** Activity (main) Resume **
Download URL=, Dir=/data/user/0/b4a.progress/files, File=elxf-specification.pdf
*** Receiver (httputils2service) Receive (first time) ***
Download completed
4173127 bytes
Upvote 0


Active Member
Licensed User
Longtime User
Thanks for trying. This proves that Erel's code works well and that the error must have to do with Android's constantly changing behavior and security settings.

I forgot that I was looking at the error message on my PC, but in reality it came from my Android Tablet.
I once saw a post by Aeric that pointed in that direction, but can't remember where.
Upvote 0


Active Member
Licensed User
Longtime User
Connection is obviously not automatic. When I first open the browser (Firefox in my case) and later start my app, it works.
Sorry to have you bothered with my stupid and/or ignorant lamentations.
john m.
Upvote 0