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

upload_2017-7-28_15-6-38.png


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

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top