S Scantech Well-Known Member Licensed User Longtime User May 29, 2024 #1 I use this code to load .png B4X: Copy MediaManager.SetMediaWithExtra(pnlCLV.GetView(x).GetView(0), GetIconLink, "image/*", CreateMap(MediaManager.REQUEST_CALLBACK: Me)) In SMM_MediaReady i do this B4X: Copy Dim Out As OutputStream Out = File.OpenOutput(File.DirInternal, Starter.SelectedFolder & WhatFileName, False) Media.Media.As(B4XBitmap).WriteToStream(Out, 50, "PNG") Out.Close Out of 200 png few of them gets this error when i load the png file using this B4X: Copy MediaManager.SetMediaFromFile(pnlCLV.GetView(x).GetView(0), File.DirInternal, Starter.SelectedFolder & WhatFileName, "image/*", Null) error code java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.setDensity(int)' on a null object reference Click to expand... When i download the png with Http job and save the job.GetInputStream. it loads perfectly fine.
I use this code to load .png B4X: Copy MediaManager.SetMediaWithExtra(pnlCLV.GetView(x).GetView(0), GetIconLink, "image/*", CreateMap(MediaManager.REQUEST_CALLBACK: Me)) In SMM_MediaReady i do this B4X: Copy Dim Out As OutputStream Out = File.OpenOutput(File.DirInternal, Starter.SelectedFolder & WhatFileName, False) Media.Media.As(B4XBitmap).WriteToStream(Out, 50, "PNG") Out.Close Out of 200 png few of them gets this error when i load the png file using this B4X: Copy MediaManager.SetMediaFromFile(pnlCLV.GetView(x).GetView(0), File.DirInternal, Starter.SelectedFolder & WhatFileName, "image/*", Null) error code java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.Bitmap.setDensity(int)' on a null object reference Click to expand... When i download the png with Http job and save the job.GetInputStream. it loads perfectly fine.
Erel B4X founder Staff member Licensed User Longtime User May 29, 2024 #2 What is the output of: Code: Copy Log("bmp: " & Media.Media) BTW, what is the purpose of this code? Why load the same image twice? Upvote 0
What is the output of: Code: Copy Log("bmp: " & Media.Media) BTW, what is the purpose of this code? Why load the same image twice?
S Scantech Well-Known Member Licensed User Longtime User May 29, 2024 #3 Erel said: What is the output of: Code: Copy Log("bmp: " & Media.Media) BTW, what is the purpose of this code? Why load the same image twice? Click to expand... Maybe i dont understand the purpose of the MediaManager.SetMediaWithExtra? It is making a http request which causes data usage if i keep repeating the code. Therefore, I save the file so i can show the image with MediaManager.SetMediaFromFile. Last edited: May 29, 2024 Upvote 0
Erel said: What is the output of: Code: Copy Log("bmp: " & Media.Media) BTW, what is the purpose of this code? Why load the same image twice? Click to expand... Maybe i dont understand the purpose of the MediaManager.SetMediaWithExtra? It is making a http request which causes data usage if i keep repeating the code. Therefore, I save the file so i can show the image with MediaManager.SetMediaFromFile.
S Scantech Well-Known Member Licensed User Longtime User May 29, 2024 #4 Here is another one (SMM_MediaReady) bmp: android.graphics.Bitmap@e879bf6 WULCjJZ.png SMM_READY ERROR: (IllegalStateException) java.lang.IllegalStateException: Can't compress a recycled bitmap Click to expand... test image https: //i.imgur.com/WULCjJZ.png remove spaces after https: Last edited: May 29, 2024 Upvote 0
Here is another one (SMM_MediaReady) bmp: android.graphics.Bitmap@e879bf6 WULCjJZ.png SMM_READY ERROR: (IllegalStateException) java.lang.IllegalStateException: Can't compress a recycled bitmap Click to expand... test image https: //i.imgur.com/WULCjJZ.png remove spaces after https:
S Scantech Well-Known Member Licensed User Longtime User May 29, 2024 #5 i noticed the Sub SMM_MediaReady get rapidly triggered and may causing issues with writetostream? I get more errors with scrolling fast. Last edited: May 30, 2024 Upvote 0
i noticed the Sub SMM_MediaReady get rapidly triggered and may causing issues with writetostream? I get more errors with scrolling fast.
Erel B4X founder Staff member Licensed User Longtime User May 30, 2024 #6 You are not using SMM correctly. SMM manages its own cache. No need to save the images yourself. Upvote 0
S Scantech Well-Known Member Licensed User Longtime User May 30, 2024 #7 Erel said: You are not using SMM correctly. SMM manages its own cache. No need to save the images yourself. Click to expand... The cache clears when the app gets closed or restart the phone. That's why I save my own file. Upvote 0
Erel said: You are not using SMM correctly. SMM manages its own cache. No need to save the images yourself. Click to expand... The cache clears when the app gets closed or restart the phone. That's why I save my own file.
Erel B4X founder Staff member Licensed User Longtime User May 30, 2024 #8 Caches are indeed temporal. If you want to download images and save them offline then use OkHttpUtils2. SMM was built for a different purpose. Upvote 0
Caches are indeed temporal. If you want to download images and save them offline then use OkHttpUtils2. SMM was built for a different purpose.