1

I am using the following code to change the phone number of an outgoing call under a certain condition. The code seems to be working. The toast appears with the old and new number but the phone dialer shows the old number in the dialing screen. If I check the call history details after the call however, it shows the new number.

How can I get the dialer screen to show the updated number?

public void onReceive(Context context,Intent intent) {
        final String oldNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        String modNumber = "";
        if (oldNumber.startsWith("xx")) {
            modNumber = oldNumber.replace("xx", "yyy");
            this.setResultData(modNumber ); 
            final String newNumber = this.getResultData();
            String msg = "Call Intercepted. Old number " + oldNumber + ", new number " + newNumber;
            Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
        }
    }

The android.permission.PROCESS_OUTGOING_CALLS is present in the manifest file.

App is deployed on a phone running Android 5.0.2 (Lollipop)

Vaibhav Mule
  • 5,016
  • 4
  • 35
  • 52
bobbyalex
  • 2,681
  • 3
  • 30
  • 51

0 Answers0