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

OutgoingCallReceiver

public class OutgoingCallReceiver extends android.content.BroadcastReceiver
OutgoingCallReceiver receives NEW_OUTGOING_CALL broadcasts from OutgoingCallBroadcaster, and passes them on to InCallScreen, possibly with a modified phone number.

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


          
        boolean alreadyCalled;
        String number;
        String originalUri;

        if (LOGV) Log.v(TAG, "Receiving intent " + intent + ".");

        alreadyCalled = intent.getBooleanExtra(
                OutgoingCallBroadcaster.EXTRA_ALREADY_CALLED, false);
        if (alreadyCalled) {
            if (LOGV) Log.v(TAG, "CALL already placed -- returning.");
            return;
        }

        number = getResultData();
        if (number == null) {
            if (LOGV) Log.v(TAG, "CALL cancelled -- returning.");
            return;
        } else if (PhoneNumberUtils.isEmergencyNumber(number)) {
            Log.w(TAG, "Cannot modify outgoing call to emergency number " + number + ".");
            return;
        }

        originalUri = intent.getStringExtra(
                OutgoingCallBroadcaster.EXTRA_ORIGINAL_URI);
        if (originalUri == null) {
            Log.e(TAG, "Intent is missing EXTRA_ORIGINAL_URI -- returning.");
            return;
        }

        Uri uri = Uri.parse(originalUri);

        if (LOGV) Log.v(TAG, "CALL to " + number + " proceeding.");

        Intent newIntent = new Intent(Intent.ACTION_CALL, uri);
        newIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, number);
        newIntent.setClass(context, InCallScreen.class);
        newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        context.startActivity(newIntent);