Get the App
SLTechnology News&Howtos  ›  Development  › 

How to optimize App startup in android

Shulou Source: shulou.com Published: 2022-06-02 06:08:35 10月03日 Update

This article mainly introduces how to optimize App startup in android, which is very detailed and has certain reference value. Friends who are interested must finish it!

Do Android development, must have been written to the startup page, here to do some initialization operations, and is to display promotion information.

A very ordinary page, the previous test also proposed to me bug, when the application is started, sometimes there is a white screen / black screen. What I could do at that time was to minimize the time-consuming operation, which was also mentioned in the above doctor's article, but I really didn't know before to optimize this problem in a thematic way.

The following is a summary of optimizing the startup page by theme (the doctor also mentioned that initialization in child threads and initialization using IntentService belong to asynchronous initialization and delayed initialization, not to mention)

Optimize the white / black screen at startup by modifying the theme

The principle please move to the doctor's article, I will not repeat, the reason why we can see the white screen or black screen, is related to our theme, because the default theme used by the system, the background color is white / black. So we customize a theme so that the default style is what we want, which optimizes the white / black screen problem.

First, let's customize a theme and set the background we want.

@ drawable/start_window

Custom background start_window.xml

* use our custom theme on the manifest file setup startup page

At this point, in order to show the effect, we simulate a white / black screen delay operation before the startup page loads.

Public class SplashActivity extends AppCompatActivity {@ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); / / initialize the white screen and black screen SystemClock.sleep (1000); setContentView (R.layout.activity_splash) / / stay for 2 seconds to enter the main page new Handler () .postDelayed (new Runnable () {@ Override public void run () {Intent intent = new Intent (SplashActivity.this, MainActivity.class); startActivity (intent); finish ();}}, 2000) }} these are all the contents of the article "how to optimize App startup in android". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Theme that is doctor background content article method article system question ordinary done home page reason value information interest principle great achievement boy. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info MariaDB Huawei vpn