FileDocCategorySizeDatePackage
ProcessOutgoingCallTest.javaAPI DocAndroid 1.5 API3310Wed May 06 22:42:46 BST 2009com.android.phone

ProcessOutgoingCallTest

public class ProcessOutgoingCallTest extends android.content.BroadcastReceiver
ProcessOutgoingCallTest tests {@link OutgoingCallBroadcaster} by performing a couple of simple modifications to outgoing calls, and by printing log messages for each call.

Fields Summary
private static final String
TAG
private static final String
AREACODE
private static final boolean
LOGV
private static final boolean
REDIRECT_411_TO_GOOG411
private static final boolean
SEVEN_DIGIT_DIALING
private static final boolean
POUND_POUND_SEARCH
private static final boolean
BLOCK_555
Constructors Summary
Methods Summary
public voidonReceive(android.content.Context context, android.content.Intent intent)


          
        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);
                }
            }
        }