Android Question [SOLVED] Error Load Bitmap to ImageView

mayahandayani

Member
Licensed User
Hello, I have code to display an Image to Imageview but I'm having this Error
B4X:
Error occurred on line: 332 (HttpJob)
java.lang.RuntimeException: Error loading bitmap.
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:539)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:517)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1376)
    at prp.poincust.httpjob._getbitmap(httpjob.java:184)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:246)
    at android.app.ActivityThread.main(ActivityThread.java:8653)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
(Exception) java.lang.Exception:  java.lang.RuntimeException: Error loading bitmap.

My code like this

B4X:
Sub DownloadImage(Link As String, iv As ImageView)
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(Link)
    Log(Link)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log("")
        Try
            iv.Bitmap = j.GetBitmap
        Catch
            Log(LastException)
        End Try
    End If
    j.Release
End Sub

whats wrong?
thanks
 
Last edited:

mangojack

Well-Known Member
Licensed User
Longtime User
The Image downloads here without error.

B4X:
Private ImageView1 As ImageView 'Global variable

Dim urlLink As String = "https://dev.propanraya.com/sigit/SahabatPropan/files/nmax_si9qcmd7.png"
DownloadImage(urlLink, ImageView1)

Might be better to upload a sample project to highlight exactly where the error is.
 
Upvote 0
Top