Android Question Trapping Job.GetBitmapSample Error

Mashiane

Expert
Licensed User
Longtime User
Hi

Im running a job...

B4X:
Dim bmp As Bitmap = Job.GetBitmapSample(100%x,100%y)

This returns a success operation, however the bitmap being read from the server does not exist. The above statement returns an error

B4X:
java.lang.RuntimeException: Error loading bitmap.

How can I trap this or detect the non-existent image within the Job variable?
 

Mashiane

Expert
Licensed User
Longtime User
Are you checking that Job.Success is true?
Yes Erel I am, all my JobDone functions are structured the same..

B4X:
Sub JobDone (Job As HttpJob)
    If Job.Success = True Then
        Select Job.JobName
        Case "registeruser"
            GetImageFromServer(Me, "http://www.xxxx.com/xxx/xxx.jpg", "getUserImage", "22")
        Case "getUserImage"
             Dim bmp As Bitmap = Job.GetBitmapSample(100%x,100%y)
             ' process the image
        End Select
   Else
       Select Job.JobName
           Case "getUserImage"
           'do something else
       End Select
   End If
End Sub

My module sub for getting images, this works

B4X:
Sub GetImageFromServer(frm As Object, iLink As String, JobName As String, phpTag As String)
    Dim job As HttpJob
    job.Initialize(JobName, frm)
    job.Tag = phpTag
    job.Download(iLink)
End Sub

It never runs the Job.Success = False of the Else statement but just gives the error msg when the image does not exist. My GetImageFromServer works well for all existing images
 
Last edited:
Upvote 0
Top