Android - Static registration for out-of-order broadcast

  Unordered broadcast is a completely asynchronously executed broadcast. It is sent through the Context.sendBroadcast() method. After the broadcast is sent out, all broadcast receivers listening to the broadcast event will receive the broadcast at almost the same time. There is no sequential order. The broadcast receiver will exist throughout the running of the program and will not be logged out. When the program is killed, it will no longer receive broadcasts. Its registration method is to register in the AndroidManifast.xml of your application. This registration method is usually called static registration. This method can be understood as the broadcast registered through the manifest file is handed over to the operating system for processing.


   Create a MysendBroadcast() method that includes an intent filter object for which to configure the specified channel.



insert image description here


   Add two broadcast receivers, MyReceiver01 and MyReceiver02, respectively, and override the onReceive method.



insert image description here



insert image description here


   Configure AndroidManifest and add MyReceiver01 and MyReceiver02 intent filters respectively, where name="com.fengdashao" is the name of the ManinActivity setting channel and must point to this name.



insert image description here


   Execute the running program and receive MyReceiver01 and MyReceiver02 respectively. The next issue will explain another registration method - dynamic registration. Corresponding to the static registration of this issue, if you have any questions, please pay attention and communicate together.



insert image description here



insert image description here



Static registration for out-of-order broadcasts

Supongo que te gusta

Origin blog.csdn.net/weixin_48591974/article/details/127947639
Recomendado
Clasificación