Strange HTTPUtils2 problem

jaminben

Member
Licensed User
Longtime User
(Moved as requested)

Hi,

I have a strange problem using the HttpUtils2 where I get an error when using my device over my mobile data network but I never get the error when my device is connected via a wi-fi connection.

The error seems to come from the HttpJob module and its:

B4X:
httpjob_getbitmap (B4A line: 122)


b = LoadBitmap(HttpUtils2Service.TempFolder, taskId)



java.lang.RuntimeException: Error loading bitmap.
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize2(CanvasWrapper.java:500)
   at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:491)
   at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1024)
   at com.jaminben.mediamanager.httpjob._getbitmap(httpjob.java:199)
   at com.jaminben.mediamanager.moviemediadetails._jobdone(moviemediadetails.java:1533)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
   at anywheresoftware.b4a.keywords.Common$4.run(Common.java:881)
   at android.os.Handler.handleCallback(Handler.java:605)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4514)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Error loading bitmap.

Not sure if its my dodgy coding thats causing the issue or something else... anyone else seen anything like this?

Thanks

Ben

EDIT

To me and my limited knowledge it appears as if it thinks the images are loaded but when it trys to load them there is nothing there.
 
Last edited:

jaminben

Member
Licensed User
Longtime User
The image file was probably not downloaded successfully. Have you checked the Job.Success value?

As far as I know it was a success (I will double check in a bit) but surely if it wasn't a success then it wouldn't just affect the device when its connected to my data provider.

I do also use:

B4X:
If Job.Success = True Then
    Job.GetBitmap
Else
    Display dummy image
End If

Thanks
 
Upvote 0

jaminben

Member
Licensed User
Longtime User
That sort of makes sense as to why it works fine when connected to a wi-fi connection but not with my data provider.


How can I fix this? Maybe add a try, catch block to HttpJob module:

B4X:
Public Sub GetBitmap As Bitmap
  Try
      b = LoadBitmap(HttpUtils2Service.TempFolder, taskId)
      Return b
  Catch

  End Try
End Sub
 
Upvote 0

jaminben

Member
Licensed User
Longtime User
I just tried that but it still gives the error... I logged the result of b from the HttpJob module:

B4X:
Public Sub GetBitmap As Bitmap
 Dim b As Bitmap
   Log("b: " & b)
   b = LoadBitmap(HttpUtils2Service.TempFolder, taskId)
   Return b
End Sub

Log Result:

B4X:
b: (Bitmap) Not initialized

Thanks
 
Upvote 0

jaminben

Member
Licensed User
Longtime User
Can I send you my project?... it'll be easier to understand what I'm doing. Don't really want to post my whole project as it has my ip address etc in it.

Thanks
 
Upvote 0
Top