Intercept and handle incoming calls:
The system emits an orderly broadcast when you make a call outside, although the broadcast will eventually be received by the broadcast receiver in the dial and the call is made, we can get the broadcast before the broadcast is delivered to the Dial broadcast receiver, and then clear the phone number that is passed to the recipient of the dialing broadcast. When the Dial broadcast receiver receives the broadcast, the phone call is canceled because the phone number is null.
Copy Code code as follows:
Intent Intent = new Intent (Intent.action_call,uri.parse ("tel:110"));
StartActivity (Intent);
Copy Code code as follows:
public class Outcallreceiver extends Broadcastreceiver {
public void OnReceive (context context, Intent Intent) {
Setresultdata (NULL); Clear the phone, the broadcast is passed to the receiver of the system, because the phone is null, cancel the call to dial
Also if you want to modify the dial phone number, you can do so
String phone = Getresultdata ()//Get Out call
Setresultdata ("12593" + phone), plus 12593 in front of the phone
}
}
Receive the dial-out telephone broadcast intent, subscribe to this intent in the <application> node of the Androidmanifest.xml file:
Copy Code code as follows:
<receiver android:name= ". Outgoingcallreceiver ">
<intent-filter android:priority= "1" >
<action android:name= "Android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>
And to make a permission declaration:
Copy Code code as follows:
<uses-permission android:name= "Android.permission.PROCESS_OUTGOING_CALLS"/>