Brief introduction of ¨ broadcasting mechanism ¨ dynamic and static registered broadcast ¨ receive system broadcast ¨ custom broadcast ¨ local broadcast n broadcast is a system-level event. n When certain events occur on the system (for example, receiving text messages, incoming calls, low power), a message is sent to the entire Android system, which is broadcast.
Every app in Android can register a broadcast of interest, so the program will only receive the broadcast content that it cares about, either from the system or from other applications.
N programmers can also customize broadcast receive broadcast n use component broadcast receiver Broadcastreceiver to receive broadcasts, broadcast receivers need to be registered to use N when receiving a broadcast, the callback function is triggered onreceive () Broadcast classification: N Standard broadcast: a broadcast that executes completely asynchronously.
After the broadcast, all broadcast receivers receive the broadcast message almost at the same time, so there is no sequencing between them. This kind of broadcast is more efficient, but it also means that it cannot be truncated.
N ordered broadcast: A broadcast that is executed synchronously.
Only one broadcast receiver will be able to receive this broadcast message at the same time, and the broadcast will continue to pass when the logic in the broadcast receiver has been executed. So at this time the broadcast receiver is in order, the priority of the broadcast receiver can receive a broadcast message, and the front of the broadcast receiver can also truncate the broadcast is being delivered, so that the subsequent broadcast receivers will not be able to receive broadcast messages.
Broadcast receivers are free to register their own broadcasts of interest, so that when a corresponding broadcast is issued, the broadcast receiver is able to receive the broadcast and process the corresponding logic internally. There are generally two ways of registering a broadcast, registering it in code and registering it in Androidmanifest.xml, where the former is also known as dynamic registration, which is also known as static registration.
Dynamic Registration monitoring Network changes
Android07-android Broadcast