This article introduces the implementation code for Android cold start to implement apps in seconds. I will share it with you. The details are as follows:
Add attributes to the corresponding activity in AndroidManifest android:theme="@style/AppSplash"
<activity android:name="" android:screenOrientation="portrait" android:theme="@style/AppSplash"> <intent-filter> <action android:name=""/> <category android:name=""/> </intent-filter> </activity>
@style/AppSplash:
<style name="AppSplash" parent=""> <item name="android:windowFullscreen">true</item> <item name="android:windowBackground">@drawable/splash</item> </style>
@drawable/splash:
<layer-list xmlns:andro> <item> <bitmap android:src="@mipmap/splash"/> </item> </layer-list>
This is enough. Of course, this is just a feeling that gives users, not really "opening" the app in seconds.
When an activity is opened, if the application to which the activity belongs has not been started, the system will create a process for this activity. It will take some time to create and initialize the process. During this time, the WindowManager will first load the window background (windowBackground) in the theme style in the APP as the preview element, and then the layout will be loaded. What I did above is to put the startup interface in the style windowBackground configuration to present it to the user as a preview element.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.