Android monitors the system for incoming calls and pops up a prompt window
1. Problems
The project has its own enterprise address book, but in the application, the contact who dials the company address book only displays a series of phone numbers because there is no corresponding information in the mobile phone address book
2. Purpose
Monitor the incoming call of the system, obtain the telephone number, query the details of the corresponding telephone number through the calling interface, and pop up the system suspension box to prompt the user.
3. Realization
First register the broadcast monitoring system for incoming calls. The monitoring system needs to register corresponding permissions for incoming calls
Code address: https://github.com/sdsjk/phone_ alert.git
Custom broadcast to monitor system incoming calls
Static registration broadcast required
Secondly, after registration and broadcasting, we need to request the interface and obtain the data after listening to the incoming call of the system and obtaining the phone number. And pop up the system suspension box.
Note: when the system hover box pops up, you need to register the permission, and check whether the permission to pop up the hover box of the application is enabled.
Telephonymanager.call in listening_ STATE_ Operation in ringing
Customize a layout file as the view to be added. The layout file is as follows
Use two background shapes
Complete code in broadcast
design sketch
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.