Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Faster loading times for activities in android app

Tags:

android

The way I have my app set up now the initial activity that launches displays an options screen which has 4 buttons. Each button when clicked.launches its own activity and layout that goes with it. But when the user clicks a button it takes almost 3-5 seconds.for the activity to open the new screen. Is there a better way of doing this so that it loads faster? Is there a way to launch all of the activities in the background at the start of the app so they are already running? What woiluld be the best/recomended way of dealing with this.

like image 403
Peter Avatar asked Dec 21 '22 09:12

Peter


2 Answers

By the sounds of it, your activities are doing too much in their onCreate method. Try moving some of the activities setup (including loading images etc) into AsyncTaks. This should hopefully reduce the load time of your activities.

like image 149
Ljdawson Avatar answered Dec 23 '22 21:12

Ljdawson


In addition to Laurence Dawson's answer, it could be a large amount of data passing through the intent that cause that lag. In this case I'd consider to change the code from using separate activities to one activity with ViewFlipper to avoid parceling/unparceling that data.

like image 35
ernazm Avatar answered Dec 23 '22 21:12

ernazm