Example of an Android program for intercepting outgoing calls

  • 2020-05-19 05:52:08
  • OfStack

Intercept and process outgoing calls:

To dial the phone system will send out an orderly broadcast, although the radio will eventually be dialing in radio receiver receives and realize telephone dialing, but we can on radio and passed to the dialing radio receiver before you get the radio, then remove to dialing the phone number of the radio receiver, when dialing radio receiver receives the broadcast, because the phone number for null, so cancel the phone call.


Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:110"));
                startActivity(intent);


public class OutCallReceiver extends BroadcastReceiver {
     public void onReceive(Context context, Intent intent) {
           setResultData(null); // Clear the phone after the broadcast is passed to the receiver of the system as the phone is null Cancel the call 
          //  Also, if you want to change your outgoing phone number, you can do so 
          // String phone = getResultData();// Get an outgoing phone 
          // setResultData( " 12593 " + phone);// Put it in front of the phone 12593
     }
}

Receive outgoing telephone broadcasts Intent, in the AndroidManifest.xml file < application > Subscribe to this Intent in the node:


<receiver android:name=".OutgoingCallReceiver">
    <intent-filter android:priority="1">
         <action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
    </intent-filter>
</receiver>

And the permission declaration should be made:


<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>


Related articles: