tos
tos

Reputation: 996

How can I make my app launch faster?

I am experimenting with an app I am developping.

When I launch the app, there is currently a 3 second delay before the app UI is usable. During the delay the screen is black, apart from the task bar and, below it, the app title bar.

I was thinking about displaying a splashscreen as a dialog in the main Activity. However, it is only displayed after those 3 seconds, which makes it useless. This means that nearly all of the 3-second delay takes place between the launch and the call to

super.onCreate(savedInstanceState).

Can anyone educate me on what is happening behing the scenes during this delay ? Is there anything I can do to shorten it ?

Upvotes: 3

Views: 2592

Answers (1)

rekire
rekire

Reputation: 47945

Try to locate the slow code and put it into a second thread.

new Thread(new Runnable() {
    @Override
    public void run() {
        // slow code goes here.
    }
}).start();

Upvotes: 3

Related Questions