以 sdk 23 源码为例:
Activity.java:
startActivity(Intent)
==> startActivity(Intent, Bundle)
==> startActivityForResult(Intent, int, Bundle)
Instrumentation.java:
==> execStartActivity(Context, IBinder, IBinder, Activity, Intent, int, Bundle)
ActivityManagerNative.java:
==> getDefault() 返回 ActivityManagerProxy 对象
==> ActivityManagerProxy#startActivity(...)
调用 mRemote.transact(...) 进行 IPC 调用
==> ActivityManagerNative.onTransact(int, Parcel, Parcel, int)
ActivityManagerService.java:
==> startActivity(...)
==> startActivityAsUser(...)
ActivityStackSupervisor.java:
==> startActivityMayWait(...)
==> startActivityLocked(...)
==> startActivityUncheckedLocked(...)
ActivityStack.java:
==> resumeTopActivityLocked(...)
==> resumeTopActivityInnerLocked(...)
ActivityStackSupervisor.java:
==> startSpecificActivityLocked(...)
==> realStartActivityLocked(...)
调用 app.thread.scheduleLaunchActivity(...)
ApplicationThreadNative.java:
==> ApplicationThreadNative$ApplicationThreadProxy#scheduleLaunchActivity(...)
调用 mReote.transact(...) 进行 IPC 调用
==> ApplicationThreadNative#onTransact(...)
ActivityThread.java
==> ActivityThread$ApplicationThread#scheduleLaunchActivity(...)
通过 Handler 发送消息 LAUNCH_ACTIVITY
==> ActivityThread$H#handleMessage(...)
==> handleLaunchActivity(...)
==> performLaunchActivity(...)
创建 Activity 实例并调用 attach(...) 方法,
同时调用 Instrumentation#callActivityOnCreate() 方法,
Activity.java:
==> performCreate(...)
==> onCreate(...)
至此,你终于看到了你熟悉的 onCreate(...) 方法!
网友评论