Android Question error dw image & try catch

Prosg

Active Member
Licensed User
Longtime User
Hello,

i use imageDownloader

I have a image who is corrupt (but i want to prevent if it's happen again)

so i have an error :

B4X:
** Service (imagedownloader) Create **
** Service (imagedownloader) Start **
All Jobs are done
httpjob_getbitmap (B4A line: 115)
b = LoadBitmap(HttpUtils2Service.TempFolder, task
java.lang.RuntimeException: Error loading bitmap.
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:521)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:499)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at com.fitnjob.prosg.httpjob._getbitmap(httpjob.java:216)
    at com.fitnjob.prosg.imagedownloader._jobdone(imagedownloader.java:263)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6837)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

so i try this

B4X:
Try
            Dim links As Map
            links.Initialize
            links.Put(imgLogo, "http://fitnjob.com/avatars/" & avatar)
            CallSubDelayed2(ImageDownloader, "Download", links)
        Catch
            Log(LastException)
            Dim tempImg As Bitmap
            tempImg.Initialize(File.DirAssets, "noavatar.png")
            imgLogo.Bitmap = tempImg   
        End Try

but it doesn't catch the error

How can i do cause if a picture is corrupt (by ftp upload for exemple) my app crash

regards
 
Top