Android Question Load Activitys without viewing them

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I have 5 activity's in my app and I have one of them as a slash / loading screen.

Just wondering rather than opening them as I require them, is there a way I can load them in the background and then open when I need them.

The reason I ask is that I am loading a number of views/layouts and it takes about 4-5 seconds to load due to be large and I thought if I can load them while the loading screen is displayed then when I go to view them, they won't take so long to display.

Any ideas on how I can do this.
 

aaronk

Well-Known Member
Licensed User
Longtime User
Yes, loading a whole heap, and can't do without them. :(

The only way I can get past this is to display the first 10 or so to allow the Activity to load then 1 second later load the rest.
But I rather load the whole lot at once.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
- Make sure that the images are not larger than they should be.
- You can remove the images from the layout file and manually load them. It will allow you to load them before the activity is created.
You can store the loaded bitmaps in a process global Map. This way you can also reuse the bitmap when the activity is recreated.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Ok, I will have a play with that and see how I go.
I am also using the UltimateListView and loading about 300 items as well in the list and each item in the list has a background image, and another image and a label so times that by 300.. (900 items plus about another 10 or so items on top of that).

I will see what I can do with some of the suggestions you made. most images are small images but I might be able to do some changes to make it smaller and see if it loads quicker.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Ok, I will have a play with that and see how I go.
I am also using the UltimateListView and loading about 300 items as well in the list and each item in the list has a background image, and another image and a label so times that by 300.. (900 items plus about another 10 or so items on top of that).

I will see what I can do with some of the suggestions you made. most images are small images but I might be able to do some changes to make it smaller and see if it loads quicker.

Could you explain a bit more? As the ULV doesn't need to load anything (and cannot hold the loaded data), I'm not sure to understand what you're trying to do.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Basically I am loading 300 items from a SQL database into the ULV.
Each item that is added has a image as the background, has another image as well as a label to display text from the SQL database.

As each item is added it takes time to load. I found if I load only 10-20 items when the Activity loads then there is no delay.
If I load all 300 items, there is a delay as it's getting a whole heap of names from the database to load in.

I have now made it only load the first 20 names from the database, then once the page loads fully then load the rest and to the user it now looks like its loading them all at once.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Is the database local? If not, maybe it's a good idea to create a local database and copy the needed data from the remote database to this local database (afterwards, you will transfer only the changes). With a local database, you can read directly the records from the Filler sub (as I do in many examples). You don't have to load anything.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
The SQL database is on the local device.

I will have a look at the Filler sub and see what I can do from there.
I will also look over some of your examples to see what I am doing different.
 
Upvote 0
Top