1. Application description of the telephone interceptor
When we enter the phone number and make a call, the system will issue an ordered broadcast (Action = "android. intent. action. new_outgoing_call "), which is expected to be sent to the broadcast receiver of the phone dial application. However, we can set a higher priority interceptor broadcast receiver (Android: Priority =" 1000 "), this allows the caster to clear the phone number before receiving the phone number ,:
Because this application should be concealed, it needs to be started on its own. When it is started on its own, the system will send a broadcast to activate components that meet the conditions (Action = "android. intent. action. boot_completed ");
II, Code Implementation
Androidmanifest. xml
<Uses-Permission Android: Name = "android. Permission. process_outgoing_cils"/> <! -- External dialing permission --> <uses-Permission Android: Name = "android. Permission. receive_boot_completed"/> <! -- Receive boot broadcast --> <application Android: icon = "@ drawable/ic_launcher" Android: Label = "@ string/app_name"> <er Android: Name = ". phonebroadcastreceiver "> <intent-filter Android: Priority =" 1000 "> <action Android: Name =" android. intent. action. new_outgoing_call "/> <action Android: Name =" android. intent. action. boot_completed "/> </intent-filter> </receiver> </Application>
Phonebroadcastreceiver. Java
Package COM. xiazdong. phonelistener; import android. content. broadcastreceiver; import android. content. context; import android. content. intent; public class phonebroadcastreceiver extends broadcastreceiver {@ overridepublic void onreceive (context, intent) {If ("5556 ". equals (this. getresultdata () This. setresultdata (null); // if the phone number is 5556, it is cleared and cannot be called }}