8.3 BroadcastReceiver2
2018-07-12 本文已影响0人
jadefly
全局广播:APP发出的广播,其他APP都会接收到,同样会接收到其他App发出的广播。
本地广播:发出的广播只会在APP内部传播,而且广播接收者也只能收到本应用发出的广播。
本地广播

注意事项:1.本地广播无法通过静态注册方式来接收,相比起系统全局广播更加高效;
2.在广播中启动Activity需添加FLAG_ACTIVITY_NEW_TASK标记;
3.在广播中弹出AlertDialog,需设置弹框类型为TYPE_SYSTEM_ALERT;
alertDialog.getWindow().setType( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
使用也大同小异:

系统广播(系统提供的的Acition)
