Android Question When trying to download image from remote, get an error "Error loading bitmap"

Rajesh Gupta

Member
Licensed User
Hello sir
My code is

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Main")
    downLoadFile
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Public Sub downLoadFile()
    Dim job7 As HttpJob
    FileName="a.txt"
    Dim  FilePath As String="http://192.168.0.36/UWS1/UWS/Temp/v.png"
    job7.Initialize("job7", Me)
    job7.Download(FilePath)
End Sub

Sub JobDone (job As HttpJob)
    If job.JobName="job7" Then
        If job.Success Then
            ImageView1.Bitmap= job.GetBitmap
            'Activity.SetBackgroundImage(job.GetBitmap)
            Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, FileName, False)
            File.Copy2(job.GetInputStream, out)
            out.Close
       
        Else
            Log("Error: " & job.ErrorMessage)
        End If
    Else
   
        Log("Error: " & job.ErrorMessage)
        ToastMessageShow("Error: " & job.ErrorMessage, True)
    End If
   
    job.Release
End Sub

On running this code, log show following error



Why there is problem in downloading file?
Please sir help me.
 

eps

Expert
Licensed User
Longtime User
That URL : http://192.168.0.36 is not a remote one, but an internal one - to your home or work network - are you connected to the WiFi and is there a machine with that IP address?

And are you able to access the file on that machine?
 
Upvote 0

Rajesh Gupta

Member
Licensed User
That URL : http://192.168.0.36 is not a remote one, but an internal one - to your home or work network - are you connected to the WiFi and is there a machine with that IP address?

And are you able to access the file on that machine?

Yes sir, this ip address is local. So there is problem. Now my code is working. Thank you so much.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…