Hi, I have an App where the user subscribes to a service of his choice , and according to the service chosen a .png file is downloaded and used as an icon to represent the service he is subscribed to . Everything works fine and I have multiple logs that check that the download was executed correctly and that the file exists.
but I keep getting this error when trying to load the .png file ( which is downloaded to DirInternal ) to an Imageview .
** Activity (selectscreen) Pause, UserClosed = false **
** Activity (billlist) Create, isFirst = true **
DB size is:1
billlist_createitem (java line: 743)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.initializeSampleImpl(CanvasWrapper.java:637)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeResize(CanvasWrapper.java:548)
at anywheresoftware.b4a.keywords.Common.LoadBitmapResize(Common.java:1371)
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.LoadBitmapResize(B4XViewWrapper.java:674)
at simbills.beta.billlist._createitem(billlist.java:743)
at simbills.beta.billlist._activity_create(billlist.java:432)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at simbills.beta.billlist.afterFirstLayout(billlist.java:104)
at simbills.beta.billlist.access$000(billlist.java:17)
at simbills.beta.billlist$WaitForLayout.run(billlist.java:82)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
*** Service (starter) Create ***
** Service (starter) Start **
Just to make sure that the file is not corrupted If download the file and copy it to the app files folder before compiling, I can then load it into the imageview by calling the path from DirAssets, that works fine. But it's no use to me as there are multiple services the user can subscribe to , and there is no way of knowing which will be chosen. Hardcoding all the possible . png files into the source code would be a waste.
Here is the code that handles the imageview:
I've tried everything, including moving the file to GetSafeDirDefaultExternal , but I still can't get this to work any help would be really appreciated .
but I keep getting this error when trying to load the .png file ( which is downloaded to DirInternal ) to an Imageview .
** Activity (selectscreen) Pause, UserClosed = false **
** Activity (billlist) Create, isFirst = true **
DB size is:1
billlist_createitem (java line: 743)
java.lang.RuntimeException: Error loading bitmap.
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.initializeSampleImpl(CanvasWrapper.java:637)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeResize(CanvasWrapper.java:548)
at anywheresoftware.b4a.keywords.Common.LoadBitmapResize(Common.java:1371)
at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.LoadBitmapResize(B4XViewWrapper.java:674)
at simbills.beta.billlist._createitem(billlist.java:743)
at simbills.beta.billlist._activity_create(billlist.java:432)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at simbills.beta.billlist.afterFirstLayout(billlist.java:104)
at simbills.beta.billlist.access$000(billlist.java:17)
at simbills.beta.billlist$WaitForLayout.run(billlist.java:82)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
*** Service (starter) Create ***
** Service (starter) Start **
Just to make sure that the file is not corrupted If download the file and copy it to the app files folder before compiling, I can then load it into the imageview by calling the path from DirAssets, that works fine. But it's no use to me as there are multiple services the user can subscribe to , and there is no way of knowing which will be chosen. Hardcoding all the possible . png files into the source code would be a waste.
Here is the code that handles the imageview:
B4X:
Private Sub CreateItem(Width As Int, Title As String,Image As String,Cur As String, Tot As String, ary As String, PaidButton As String) As Panel
' GetData
Dim p As B4XView = xui.CreatePanel("")
Dim height As Int = 180dip
If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then height = 150dip
p.SetLayoutAnimated(0, 0, 0, Width, height)
p.LoadLayout("Card1")
'p.SetColorandBorder(xui.Color_RGB(58,101,114),5dip,xui.Color_White ,7dip)
'p.Width =20dip
p.Tag= False
lblExp.Text = ary
lblContent.Text = Title
Label1.Text = Cur
Label3.Text = Tot
Dim Path As String = File.DirInternal
ImageView1.SetBitmap(xui.LoadBitmapResize(Path, Image, ImageView1.Width, ImageView1.Height, True))
Return p
End Sub
I've tried everything, including moving the file to GetSafeDirDefaultExternal , but I still can't get this to work any help would be really appreciated .