How to abort outgoing call and then resume after user's approval
I want to abort the outgoing calls and then originate the call on the same number after some approval from user. Here is my outgoing Call receiver code
public class OutgoingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, OutgoingCallOptions.class);
final String phoneNumber = intent
.getStringExtra(Intent.EXTRA_PHON开发者_JS百科E_NUMBER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra(Intent.EXTRA_PHONE_NUMBER, phoneNumber);
context.startActivity(i);
setResultData(null);
}
}
After the user presses a button on OutgoingCallOptions Activity, I want to call the same number. I am try to do this using
String phoneNumber = getIntent().getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if (phoneNumber != null){
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
Problem is that my broadcast receiver also captures this call which I am trying to place. How can I avoid this in my broadcast receiver?
Thanks in Advance.
精彩评论