前言
此前我用较长的篇幅来介绍Android应用程序的启动过程(根Activity的启动过程),这一篇我们接着来分析Service的启动过程。建议阅读此篇文章前,请先阅读Android深入四大组件(一)应用程序启动过程(前篇)和Android深入四大组件(一)应用程序启动过程(后篇)这两篇文章。
1.ContextImpl到ActivityManageService的调用过程
要启动Service,我们会调用startService方法,它的实现在ContextWrapper中,代码如下所示。
frameworks/base/core/java/android/content/ContextWrapper.java
public class ContextWrapper extends Context { Context mBase; ... @Override public ComponentName startService(Intent service) { return mBase.startService(service); } ... }