1.ActivityThread
/**
* This manages the execution of the main thread in an
* application process, scheduling and executing activities,
* broadcasts, and other operations on it as the activity
* manager requests.
*
* {@hide}
*/
framework的源码对ActivityThread的解释,主要是说在应用进程的主线程中管理执行工作,
例如Activity和广播的调度工作及activity管理者的请求处理吧。
2.Instrumentation
/**
* Base class for implementing application instrumentation code. When running
* with instrumentation turned on, this class will be instantiated for you
* before any of the application code, allowing you to monitor all of the
* interaction the system has with the application. An Instrumentation
* implementation is described to the system through an AndroidManifest.xml's
* <instrumentation> tag.
*/
An Instrumentation implementation is described to the system through an AndroidManifest.xml's
大概意思是说 这个仪表是通过AndroidMaifest.xml's的配置来向系统描述这个应用,
比如有哪些Activity,Service注册了等。
这里我是想简单描述Activity的启动步骤
1、startActivity()后会执行ActivityThread中的 performLaunchActivity(ActivityClientRecord r, Intent customIntent),
2、该方法中的Instrumentation的实例执行newActivity(ClassLoader cl, String className,Intent intent)方法,
3、方法中主要是执行(Activity)cl.loadClass(className).newInstance()生成Activity,如果在AndroidMenifest.xml中没有
注册应该就会报异常。生成Activity实例后就调用attach()方法,根据Activity的一些信息创建PhoneWindow,WindowManger;接着接续在 performLaunchActivity方法中执行mInstrumentation.callActivityOnCreate(activity, r.state),也就是Activity回调oncreate方法,接着Activity就执行setContentView(),其实就是window调用setContentView(int),及初始化actionbar,这个window实际上是PhoneWindow实例。表层的启动过程大概就是这样吧,当然这里没有涉及binder通信机制。
#这里提到了Instrumentation 类其实是因为Android插件化开发涉及过。就是通过Instrumentation执行欺骗ActivityManagerService。
/**
* This manages the execution of the main thread in an
* application process, scheduling and executing activities,
* broadcasts, and other operations on it as the activity
* manager requests.
*
* {@hide}
*/
framework的源码对ActivityThread的解释,主要是说在应用进程的主线程中管理执行工作,
例如Activity和广播的调度工作及activity管理者的请求处理吧。
2.Instrumentation
/**
* Base class for implementing application instrumentation code. When running
* with instrumentation turned on, this class will be instantiated for you
* before any of the application code, allowing you to monitor all of the
* interaction the system has with the application. An Instrumentation
* implementation is described to the system through an AndroidManifest.xml's
* <instrumentation> tag.
*/
An Instrumentation implementation is described to the system through an AndroidManifest.xml's
大概意思是说 这个仪表是通过AndroidMaifest.xml's的配置来向系统描述这个应用,
比如有哪些Activity,Service注册了等。
这里我是想简单描述Activity的启动步骤
1、startActivity()后会执行ActivityThread中的 performLaunchActivity(ActivityClientRecord r, Intent customIntent),
2、该方法中的Instrumentation的实例执行newActivity(ClassLoader cl, String className,Intent intent)方法,
3、方法中主要是执行(Activity)cl.loadClass(className).newInstance()生成Activity,如果在AndroidMenifest.xml中没有
注册应该就会报异常。生成Activity实例后就调用attach()方法,根据Activity的一些信息创建PhoneWindow,WindowManger;接着接续在 performLaunchActivity方法中执行mInstrumentation.callActivityOnCreate(activity, r.state),也就是Activity回调oncreate方法,接着Activity就执行setContentView(),其实就是window调用setContentView(int),及初始化actionbar,这个window实际上是PhoneWindow实例。表层的启动过程大概就是这样吧,当然这里没有涉及binder通信机制。
#这里提到了Instrumentation 类其实是因为Android插件化开发涉及过。就是通过Instrumentation执行欺骗ActivityManagerService。