I have a BroadcastReceiver catching ACTION_NEW_OUTGOING_CALL events.
In the onReceive() method I'm sending the supplied number to a new ListActivity, where the user gets to choose various new destination numbers from a list.
When the user selects a new number from the list I'm then starting a new ACTION_CALL intent with the new number in the URI field. Alternatively, the result might be the original number.
Whatever the new number is, it has to be dialled immediately and not processed any further.
How can I let the BroadcastReceiver know that this resulting number shouldn't be processed yet again?
I resolved this by implementing a "Bypass Prefix" in my BroadcastReceiver. If my client app wants to call a number directly it simply prepends the prefix before invoking the ACTION_CALL Intent.
If the dialed number has the (hard coded) prefix, the BroadcastReceiver strips the prefix and allows the call to proceed as normal:
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(action)) {
String number = getResultData();
if (number.startsWith(BYPASS_PREFIX)) {
setResultData(number.substring(BYPASS_PREFIX.length()));
} else {
// do additional processing
}
}
}
This solves two problems in one go - not only does this stop the call looping, it also gives me a way to bypass the additional processing for specific numbers by storing the prefix in their phone book entries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With