Android Question Activity.SetBackgroundImage not working on Android 5.1.1

Arf

Well-Known Member
Licensed User
Longtime User
Hi,
I've been testing my app on different platforms - Samsumg S3 phone (android 4.2.2) , Hudl 2 tablet (5.1) and
Nexus 7" (5.1.1).

App works fine on all, but in one of my activities an image does not get loaded and displayed.
I load the layout for the activity, no problems, then do this:

B4X:
Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "train.jpg"))

Doesn't load up on the nexus, does on the others.
Nexus resolution: 1920 x 1200 pixels
S3 resolution: 1280 x 720 pixels
Hudl resolution: 1920 x 1200 pixels

The image I am trying to load is 1559 x 2859 pixels and my app works in portait orientation only.

Any ideas? Thanks
 

Mark Read

Well-Known Member
Licensed User
Longtime User
Have you tried "LoadBitmapSample" instead. Maybe you have a memory problem.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Thanks.
I have just noticed in the log window that I am getting "Downsampling image due to lack of memory" messages, this is when displaying other images in the app so I guess the same memory shortage is what may be causing the issue above (it is a large image).

I'll try clear the tablet's cache and reboot and see if this helps.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Ok. The images I am getting the 'downsample' message for, they are 40kB png's, and there are 28 on the page.
The big image that's not loading in the activity is a 780kB PNG.
So the pictures aren't massive..
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
OK, the big image is working now that I'm using LoadBitmapSample, thanks.

I still have a problem with the smaller, numerous bitmaps. Basically I have an array of 28 buttons that are placed on an activity, and in the designer I allocate a specific bitmap to each button. Think of it as a table of cards, all with the same image (cards back facing up).
Then in my app, another activity loads this card array activity into a panel. From here you can click on a card to turn it over, and at this point I set a new bitmap for the card. There is also a 'try again' button which attempts to clear the panel and repopulate it with its starting position, like this:
B4X:
Panel1.RemoveAllViews
Panel1.LoadLayout("CardBoard")

It is when the 'try again' button is clicked that I get a slowdown and 'downsampling' messages and an eventual crash.

So, is my strategy of using the designer to allocate the inital image to the buttons not optimal?, or is the way I am trying to re-draw the card board not optimal? I can try use LoadBitmapSample an initialise the images to the buttons programatically after the panel is drawn, and if I do should I just use Button.Width and Button.Height as the arguments for the 'sample' function?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I seem to have fixed it now but manually drawing the blank cards to the buttons instead of re-loading the Activity.
Thanks.
 
Upvote 0
Top