前言 本文基于Android 11,参考《Android进阶解密》一书资料。了解Service的启动和绑定流程,以及Service的Context创建过程。 由于基于分析流程,忽略很多细节分支。各位在看源码的时候,要尽可能忽略细节,分析整体流程之后,还有精力的话再去看细节。例如有些属性是在后面赋值的,如果在前面追究,难哦。 另:阅读这种流程需要很大的耐心和毅力。建议在心情愉悦想要学习的时候搭配源码一起食用。 一、Service 的启动流程 1、ContextImpl.startService 启动一个Service,通常在Activity调用startService来启动。 @Override public ComponentName startService(Intent service) { return startServiceCommon(service, false, mUser); } 2、ContextImpl.startServiceCommon startServiceCommon检查intent内容是否合法,然后做一些离开当前进程的准备操作。调用...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Get in touch with getAttribution
Contact getAttribution, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack