Activity启动大致流程
![这里写图片描述](https://img-blog.csdn.net/20180331150238199?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3NpbmF0XzMzODc4ODc4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
public static void main(String[] args) {
......
Looper.prepareMainLooper();
ActivityThread thread = new ActivityThread();
/**将ApplicationThread这个binder实例交给AMS,该binder持有主线程
*的一个Handle H,以便AMS可以调用,也就是由AMS系统进程去请求
* Acticity的各个生命周期和状态 比如启动调用
* ApplicationThread.scheduleLaunchActivity,跨进程
*/
thread.attach(false);
if (sMainThreadHandler == null) {
sMainThreadHandler = thread.getHandler();
}
......
/**开启消息循环,里面messageQueue.next()会阻塞,阻塞时会释放cpu资
*源,底层实现。一有ApplicationThread传过来的消息就处理,不会使得线
*程卡死在这个循环,因为一有请求都处理了。
*/
Looper.loop();
throw new RuntimeException("Main thread loop unexpectedly exited");
}