SoFunction
Updated on 2025-04-09

Optimize the startup speed of Android practical APP

The APP startup speed is very important. The slow start speed of the APP may cause a poor user experience, especially after using Android studio recently. If you do not open the app for a long time, the startup speed will be particularly slow. Let’s discuss the reasons and solutions that affect the startup speed of the app.

Detection start time

First of all, we need to know the start time of the app, and then you can also use your feelings. Here I will teach you a way to show off:

adb shell am start -W [packageName]/[.MainActivity]

The startup time can be detected using the adb command, as shown below:

./adb shell am start -W ""/".MainActivity"
Starting: Intent { act= cat=[] cmp=/.MainActivity }
Status: ok
Activity: /.MainActivity
ThisTime: 7524
TotalTime: 7524
WaitTime: 7551
Complete
  • For application package name
  • .MainActivity is the main page function to be started
  • WaitTime is the startup time we are concerned about

So does 7551 count as long as the startup time? The answer is very long. . . This is an app that has not been started for a long time. When it is launched for the first time, it has a long startup time. Let’s talk about how to reduce it.

Reduce application startup time

The app startup process, simply put, mainly includes two parts:

  • Application
  • OnCreate method of startup interface

Therefore, the easiest way is to minimize the time-consuming operation in these two methods.

The above method solves the startup speed from the code, but the user still feels slow when starting. What should I do? Directly upload the code:

<!-- Base application theme. -->
<style name="AppTheme" parent="">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorAccent</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="">
<item name="android:windowBackground">@color/colorLauncher</item>
</style>

This is the android style file, which is the theme style of the startup interface. Add android:windowBackground to the theme style of your app homepage and put the background picture of the app. This way, even if the app starts slowly, the background will be loaded first, which will create an illusion for the user, thinking that the app has been started.

Instant Run

How much do you know about the new feature of Android studio Instant Run?

Instant Run is also one of the factors that affect the startup, but this is not available in the released version, so don’t worry.