Java – Android captures new outgoing calls

Android captures new outgoing calls… here is a solution to the problem.

Android captures new outgoing calls

Possible Duplicate:
Android: Redirect outgoing calls

The requirement is to replace the newly dialed number with another number. I caught the ACTION_NEW_OUTGOING_CALL event and used Intent.EXTRA_PHONE_NUMBER to get the current dialed number, and then I used setResultData in my class (extension BroadcastReceiver) to replace the calling number. Basically the code is,

if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {

String phonenbr = 
    intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
   Log.d("OutGoingNum", "phonenbr is " + phonenbr);

if (phonenbr.startsWith("00")) {
    setResultData("12345678");
   } 
  }

My code works fine in the Android emulator, but on the device the code only works with redials. When you call a number through the dial pad, it does not work. Please help.

Related Problems and Solutions