The Activity starts the method stack

1. Instrumentation.execStartActivity 2. ActivityManagerProxy.startActivity 3. ActivityManagerService.startActivity 4. ActivityStack.startActivityMayWait 5. ActivityStack.startActivityLocked 6. ActivityStack.startActivityUncheckedLocked 7.  Activity.resumeTopActivityLocked 8. ActivityStack.startPausingLocked 9. ApplicationThreadProxy.schedulePauseActivity 10. ApplicationThread.schedulePauseActivity 11. ActivityThread.queueOrSendMessage 12. H.handleMessage 13. ActivityThread.handlePauseActivity 14. ActivityManagerProxy.activityPaused 15. ActivityManagerService.activityPaused 16.  ActivityStack.activityPaused 17. ActivityStack.completePauseLocked 18. ActivityStack.resumeTopActivityLokced 19. ActivityStack.startSpecificActivityLocked 20. ActivityManagerService.startProcessLocked 21. ActivityThread.main 22. ActivityManagerProxy.attachApplication 23. ActivityManagerService.attachApplication 24. ActivityManagerService.attachApplicationLocked 25. ActivityStack.realStartActivityLocked 26. ApplicationThreadProxy.scheduleLaunchActivity 27. ApplicationThread.scheduleLaunchActivity 28. ActivityThread.queueOrSendMessage 29. H.handleMessage 30. ActivityThread.handleLaunchActivity 31. ActivityThread.performLaunchActivityCopy the code

conclusion

There are many steps involved in the entire application startup process, but in general, there are five main stages:

  • The Binder interprocess communication notifies ActivityManagerService that it wants to start an Activity.
  • ActivityManagerService sends the Launcher into Paused state through the Binder interprocess communication mechanism.
  • Step 3: The Launcher uses the Binder interprocess communication mechanism to tell ActivityManagerService that it is ready to go to Paused, and ActivityManagerService creates a new process, It is used to start an ActivityThread instance in which the Activity to be started will run.
  • Step 4: ActivityThread passes a Binder object of type ApplicationThread to ActivityManagerService through the Binder interprocess communication mechanism. So that ActivityManagerService can later communicate with the Binder object;
  • The ActivityManagerService notifies the ActivityThread through the Binder interprocess communication mechanism that it is now ready to actually start the Activity.

This completes the application startup process, which is essentially the default Activity to start the application.