Android Question CLOSED - LoadBitmapResize problem - never returns

Robert Valentino

Well-Known Member
Licensed User
Longtime User
When I use LoadBitmapResize on the attached bitmap it just hangs

B4X:
                    NewTitleBitmap.TitleBitmap = LoadBitmapResize(Path, FolderFile, 40dip, 40dip, True)

If I just Open the bitmap with Paint.Net and SAVE it the size changes from 345kb to 1.2meg but then LoadBitmapResize works just fine.

THIS is the only bitmap (of 600+) that has ever given me a problem.

Very suprised the LoadBitmapResize did not fail or throw an error but just never returns
 

Attachments

  • Folder-Problem.jpg
    Folder-Problem.jpg
    345.1 KB · Views: 80

drgottjr

Expert
Licensed User
Longtime User
no problem here.
B4X:
        imageview.Bitmap = LoadBitmapResize(File.DirAssets,"Folder-Problem.jpg", 40dip, 40dip, True)
 

Attachments

  • valentino.png
    valentino.png
    6.6 KB · Views: 77
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Interesting. I will make a test program and try it on all my devices (they are all Samsung)
Android v5.1.1 - v8.0.0

What Android version did you run on? and I guess B4A version and Java

I am still on B4A 9.90 and Java jdk-11.0.3 and using SDK settings - <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="28"/>

I guess all these matter
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
nexus 5x 8.10 9.90 java 8.xxx same sdk settings. no emulator? i was a little confused by your initial post. first you say loadbitmapresize() hangs, then below that you say loadbitmapresize() loads just fine. i vote for the code that lets loadbitmapresize() load just fine :)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here is another confirmation to Dr Gott's finding: B4A 9.9 , Samsung Galaxy Tab A 5.1.1, java 11. It works just fine for me.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Here is a test program I wrote and the Folderbad.jpg (can't upload the good folder too large)

Has the actual directory I am loading from. Hangs (fails) / Never returns every time.

This is on a Samsung Galaxy Tab A SM-T580 Running Android 8.1.0

No sure what is happening. But strange that some have been able to load this.
 

Attachments

  • TestLoadBmp.zip
    8.5 KB · Views: 103
  • Folderbad.jpg
    Folderbad.jpg
    345.1 KB · Views: 74
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i have some issues with the way you handle the runtime permissions, so i would have to modify.
it would be helpful to have the actual image. i'm guessing now106 is a radio station's website. can i download the original from there?
please advise exactly what "/storage" is. accessing direxternal this way is not how we're supposed to do it. please confirm where and what it is. tks.
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
NOTE - this is just a test program I made to see if anyone else could reproduce the error. Sorry that you don't like the way I handled the permissions. But I just cut and pasted enough code to get the test to work, not trying to make a app here.

106 is a CD cover image. Only copy of it I got was uploaded. With program.

Can't say where I downloaded from, just searched web or it automatically came when ripping CD Can't remember

Forgot to add Storage is a micro SD card 256gig
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
this is just a test program I made to see if anyone else could reproduce the erro
I don't think anybody can test your program exactly like you have it with a folder name like this:
"/storage/3338-6531/Music/Various Artists/Now That's What I Call Music!/Volume-106"
Your runtimepermissions code is very complicated , so I simplified it and here is the full code that works. I can attach the project if you like, but it is self explanatory
B4X:
Sub Globals
    Dim fname2 As String 'the file needs to be in the assets folder: "Folder-Problem.jpg"
    Private imageview As ImageView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")    'has imageview
    fname2 = "Folder-Problem.jpg"
    Dim rp As RuntimePermissions   'need runtimepermissions lib cheched
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    wait for Activity_PermissionResult(Permision As String, Result As Boolean)
    If Result = False Then
        MsgboxAsync("No permission to access external storage", "")
        Return
    Else    
        Log("granted permission")
        If File.Exists(File.DirRootExternal, fname2) =False Then
            File.Copy(File.DirAssets,fname2, File.DirRootExternal, fname2)
            Log("file copied to dir external")
            imageview.Bitmap = LoadBitmapResize(File.DirRootExternal,"Folder-Problem.jpg", 40dip, 40dip, True)
        End If

    End If
End Sub
I used the same file you were having trouble with, but found no problems
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Yeah I am sure of that.

But if you have micro SD card you can create the sub directories under it "/Music/Various Artists/Now That's What I Call Music!/Volume-106" and then it is just a matter of what the prefix is to get to your SD card

Just got around to testing the test program on on my S7 (kind of same path /storage/3864-6563 device number is different after storage) and WORKS Fine.

So must be something with the Tab A SM-T580 (not sure what it could be) I will look into this more if possible.

Was thinking maybe storage read error, but then I deleted the file and copied a good file there and then recopied the bad file and it still happened so not likely that

Going to mark this as Closed after this post.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Going to mark this as Closed after this post.
This thread should not be closed yet. If the OP is using a micro SD card, then he is using an external removable storage. It has nothing to do with File.DirRootExternal or runtimepermissions. He needs to use the class here:
Here is an excerpt of the first paragraph:
1. External storage means a real sd card or a connected mass storage USB device.
2. It has nothing to do with File.DirRootExternal / DirDefaultExternal which actually point to an internal storage.
3. It has nothing to do with runtime permissions.
4. You can use RuntimePermissions.GetAllSafeDirsExternal to directly access a specific folder on the SD card.
 
Upvote 0
Top