Skip to content Skip to sidebar Skip to footer

Outgoing Call Don't Start

I'm writing an application that: Intercepts an outgoing call Shows a dialog asking whether the call is 'personal' or 'business' ('Aziendale' in italian) If 'personal', makes the

Solution 1:

The problem is actually quite simple once you figure it out.. You have a broadcast receiver for outgoing calls, which intercepts them and shows your dialog. After you choose if the call is private or business, you place the call with the modified number...and guess who intercepts the call? Your broadcast receiver, and so the loop goes. Tho prevent this infinite loop, the only way I know of, is to disable the broadcast receiver before placing the modified call, and enabling it again after the call ends.

privatevoidmakeCall1(Stringnumber)  {
    PackageManager pm = mContext.getPackageManager();
    ComponentName componentName = newComponentName(mContext, OutgoingCallReceiver.class);
    pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    Intent callIntent = newIntent(Intent.ACTION_CALL, Uri.parse(number));
    startActivity(callIntent);
    // Now wait for the call to end somehow and afterwards ->// pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}

I hope I was of help!

Solution 2:

It is possible to intercept the outgoing call, and make alterations using specific BroadcastReceiver. See this entry from Android developer blog.

Now, the issue is BroadcastReceivers need to process it immediately. Here, we don't know how much time user is taking to respond to dialog.

As shown in example from blog entry above, cancel the broadcast, show dialog and dial after user responds. But this time, place an extra flag in intent, that this call has been already processed, so your BroadcastReceivers doesn't process it next time.

Post a Comment for "Outgoing Call Don't Start"