前言:項目中被诟病多媒體開機第一次啟動很慢,大約3s的黑屏,後續點開啟動正常,其中什麼原理呢?這就涉及到系統的三種啟動模型
1.Cold Start,冷啟動
system--->
loding and launching the app
displaying a blank window
createing the app process
process--->
creating the application
launching the main thread
creating the main activity
inflating views
laying out the screen
perfoming the initial draw
main activity place blank window
2.Hot Start,熱啟動
前台activity因記憶體不足,被系統銷毀重建的過程(重建流程同冷啟動)
3.Warm Start
- 使用者點選傳回,并重新運作
-
activity不在前台,被系統銷毀,由使用者主動運作
可通過onSaveInstance儲存狀态
4.APP啟動慢常見問題
- Application.onCreate中執行了過重的操作,如I/O操作,頻繁建立對象等
-
Activity.onCreate
布局過于複雜
Loading and decoding bitmaps
blocking screen drawing on disk or network I/O
Rasterinzing vectordrawable objects
initialztion of other subsystem of the activity