D
D
Dmitry Sokolov2017-05-05 09:08:24
Android
Dmitry Sokolov, 2017-05-05 09:08:24

How to answer an incoming call from a custom activity?

With grief in half, I figured out how to spit out my activity on top of the native incoming call window:

new Handler().PostDelayed(() =>
{
    Intent callIntent = new Intent(context, typeof(CallActivity));
    callIntent.AddFlags(ActivityFlags.NewTask);
    callIntent.SetFlags(ActivityFlags.NewTask);
    callIntent.PutExtra("Number", intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber));
    context.StartActivity(callIntent);
}, 1500);

But then you need to prompt the user to answer or reject the call. The entire network is crammed with the following piece of code:
Intent button = new Intent(Intent.ActionMediaButton);
button.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Down, Keycode.Headsethook));
SendOrderedBroadcast(button, "android.permission.CALL_PRIVILEGED");

But it doesn't work (target API 22-23). What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-05-05
@TrueBers

There is no official documented API for this as far as I know. It all depends on the firmware.
You need to fence your crutch for each device. In total, there are a dozen and a half methods of raising the tube, probably.
Once I found examples on github, look there.
Or decompile any sane caller from the market, see how they do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question