关于Android的解析,有很多优质内容,看了后记录一下阅读笔记,也是一种有意义的事情,
今天就看看“那个写代码的”这位大佬关于广播的梳理,
https://blog.youkuaiyun.com/a572423926/category_11509429.html
https://blog.youkuaiyun.com/a572423926/article/details/121760258
广播的原理很清晰,类似一种观察者模式,控制中心把广播发送给注册者(观察者),但是android中的实现细节较多。

这里通过一个am命令发送受保护的广播,查看抛出的异常,看相关堆栈。
am broadcast -n com.example.test/.AppInstallReceiver -a android.intent.action.SCREEN_ON
am broadcast -n com.example.test/.AppInstallReceiver -a android.intent.action.SCREEN_ON
Broadcasting: Intent { act=android.intent.action.SCREEN_ON flg=0x400000 cmp=com.example.test/.AppInstallReceiver }
Exception occurred while executing 'broadcast':
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.SCREEN_ON from pid=18179, uid=2000
at com.android.server.am.

最低0.47元/天 解锁文章
451

被折叠的 条评论
为什么被折叠?



