I am writing an application that gives a dialog(dialog which is an activity) for every international outgoing call. the application interrupts the outgoing call and gives an alert for all the international calls. On the users confirmation, a new call with the same number is placed.
My app is very similar to this one Outgoing call don't start
However my broadcast receiver receives even the outgoing call i place from my application, this leads to an infinite loop. I am using the below code to disable the broadcast receiver after the call is placed from my app.
private void makeCall1(String number) {
PackageManager pm = mContext.getPackageManager();
ComponentName componentName = new ComponentName(mContext,OutgoingCallReceiver.class);
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
Intent callIntent = new Intent(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);
}
How can i retrieve the call ended notification of the call that was placed by me so that i can write some code to enable the broadcast receiver for the future calls.