For outgoing calls: I did the following as a work around and it is working fine. I created an outgoing receiver with all permissions required in manifest..
Called the Activity after a delay by using a handler.
Like this:
@Override
public void onReceive(Context context, Intent intent)
{
c = context;
setResultData(null);
phonenumber = getResultData();
if (phonenumber == null)
{
phonenumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
}
setResultData(phonenumber);
callActionHandler.postDelayed(runRingingActivity, 1000);
}
Handler callActionHandler = new Handler();
Runnable runRingingActivity = new Runnable()
{
@Override
public void run()
{
Intent intentPhoneCall = new Intent(c, OutgoingCallActivity.class);
intentPhoneCall.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intentPhoneCall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.startActivity(intentPhoneCall);
}
};
You can use the phone number to send it to the new activity.
src