Android broadcast connection realizes monitoring phone status (phone status, interception)
First, let's understand the mechanism of the next listener.
Android has two event handling mechanisms: listening and callback.
A event handling based on listening
It mainly involves three types of objects: eventsource, event and EventListener
The flow chart of event handling by the listening mechanism is as follows (delegation):
1: You need to add permissions to the androidmanifest.xml list
2: Pay attention to the level of events when registering for broadcasting (level - 1000 ~ 1000 in Android)
See androidmanifest.xml for detailed configuration
3: Write the broadcast implementation class. Here, you need to inherit the broadcastreceiver to implement the onReceive () method
The source code of the program is as follows:
The above content introduces the relevant knowledge of Android broadcast connection to monitor the phone status (phone status, interception). I hope it will be helpful to you!