if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (LOGV) Log.v(TAG, "Received intent " + intent + " (number = " + number + ".");
/* Example of how to redirect calls from one number to another. */
if (REDIRECT_411_TO_GOOG411 && number.equals("411")) {
setResultData("18004664411");
}
/* Example of how to modify the phone number in flight. */
if (SEVEN_DIGIT_DIALING && number.length() == 7) {
setResultData(AREACODE + number);
}
/* Example of how to route a call to another Application. */
if (POUND_POUND_SEARCH && number.startsWith("##")) {
Intent newIntent = new Intent(Intent.ACTION_SEARCH);
newIntent.putExtra(SearchManager.QUERY, number.substring(2));
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
setResultData(null);
}
/* Example of how to deny calls to a particular number.
* Note that no UI is displayed to the user -- the call simply
* does not happen. It is the application's responaibility to
* explain this to the user. */
int length = number.length();
if (BLOCK_555 && length >= 7) {
String exchange = number.substring(length - 7, length - 4);
Log.v(TAG, "exchange = " + exchange);
if (exchange.equals("555")) {
setResultData(null);
}
}
}