Take the 2-minute tour ×

I'm trying to end a new outgoing call after few seconds. Here is my code:

public class phonecalls extends Activity {
    ComponentName cn;
    public void onCreate(Bundle savedInstanceState) {
    private void call() {
        try {
            Intent callIntent = new Intent(Intent.ACTION_CALL);
            cn = new ComponentName(getApplicationContext(), Receiver.class);
        } catch (ActivityNotFoundException activityException) {
            Log.e("dialing-example", "Call failed", activityException);

My receiver class is:

public class Receiver extends BroadcastReceiver {
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {

I am unable to abort the outgoing call. I'm new to Android and can't seem to get this to work.

share|improve this question

4 Answers 4

You can't end a call in Android. At the moment you are calling startActivity(callIntent) you are giving up control to the native caller application. The call can now only be aborted through the phone application.

Besides that your code after starting the call does not make much sense. Your are not doing anything with the ComponentName that your are creating, so the onReceive method of your Receiver will never be called. Also if the receiver would be called the code in the onReceive method won't do anything to alter the state of the phone call.

share|improve this answer

The BroadcastReceiver class should be intercepting all calls. Check if the receiver class is registered correctly in AndroidManifest.xml:

<receiver android:name="Receiver" android:exported="true" android:enabled="true">
    <intent-filter android:priority="1">
        <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        <action android:name="android.intent.action.PHONE_STATE" />
        <category android:name="android.intent.category.DEFAULT" />

That said, I don't believe that it's possible to cancel the call after the receiver function completes. I've tried moving setResultData(null) into a thread with a few seconds delay, but I believe the reason this has no effect is because the intent has already been executed and the call has been started.

The only way that this might be possible is getting your hands dirty with internal API calls in PhoneFactory. There have been many attempts to do this (to my knowledge without success), and there is a resounding "do not do this!" from the community.

share|improve this answer
If you're trying to end the call after setResultData() (i.e. in-call), I've posted an answer here. –  Paul Lammertsma Jun 27 '11 at 21:50

You could enable the Airplane mode (need proper setting) and disable it shortly after.

Of course this would imply a loss of 3G connectivity for a short while (some seconds).

share|improve this answer

My Solution

Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);              
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
getContext().sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
share|improve this answer

Your Answer


