动态注册过程:
ContextWrapper.registerReceiver-->
ContextImpl.registerReceiver-->
ContextImpl.registerReceiverInternal-->
ActivityManagerNative.getDefault().registerReceiver-->
ActivityManagerService.registerReceiver-->
接着会把远程的InnerReceiver和IntentFilter对象存储起来
发送和接收过程:
ContextWrapper.sendBroadcast-->
ContextImpl.sendBroadcast-->
ActivityManagerNative.getDefault().boradcastIntent-->
ActivityManagerService.broadcastIntent-->
ActivityManagerService.broadcastIntentLocked-->
BroadcastQueue.scheduleBroadcastsLocked-->
BroadcastQueue.processNextBroadcast-->
BroadcastQueue.deliverToRegisteredReceiverLocked-->
BroadcastQueue.performReceiveLocked-->
ApplicationThread.scheduleRegisteredReceiver-->
InnerReceiver.performReceive-->
LoadedApk.ReceiverDispatcher.performReceive-->
ActivityThread.H.post(args)-->
args.run-->
BroadcastReceiver.onReceive
No1:
四大组件都是在应用安装时由PMS(PackageManagerService)解析并注册的。
No2:
从Android3.1开始,处于停止状态的应用同样无法接收到开机广播FLAG_INCLUDE_STOPPED_PACKAGES
而在Android3.1之前,处于停止状态的应用是可以收到开机广播的