其他分享
首页 > 其他分享> > 【Android高阶】APP启动过程一些重要步骤总结

【Android高阶】APP启动过程一些重要步骤总结

作者:互联网

main入口函数创建了一个ActivityThread对象之后,通过bindler机制 回调了handleLaunchActivity()方法 ->

ActivityThread#handleLaunchActivity ->

WindowManagerGlobal.initialize() ; performLaunchActivity ->

activity = mInstrumentation.newActivity(r.packageInfo.getClassLoader())  ; activity.attach()  ->

mWindow = new PhoneWindow();installDecor创建出DecorView; mWindow.setCallback(this)(事件分发用到这个)  -> 

performLaunchActivity返回了activity实例,不为空的话  -> 

ActivityThread#handleResumeActivity

把view显示到屏幕上的过程:

ActivityThread#handleResumeActivity ->

windowManager.addView(decor) ->

windowManagerImpl.addView(decor) ->

windowManagerGlobal.addView(decor) ->

root = new ViewRootImpl; root.setView(decor) ->

requestLayout; mWindowSession.addToDisplay()(IPC), 这样view显示到屏幕中了

其中:setContentView是把layout加载后挂到decorView的R.id.content的fragment中。

注意过程中的一些概念:

ActivityThread

WindowManager

WindowManagerImpl

WindowManagerGlobal

PhoneWindow

DecorView

ViewRootImpl

 

标签:decor,performLaunchActivity,APP,ActivityThread,handleLaunchActivity,addView,acti
来源: https://blog.csdn.net/yearningseeker/article/details/113754838