DEV Community

shiv
shiv

Posted on

How to reject incoming call in xamarin android

how to reject incoming call ...? Please suggest me the right way.
I have the following working code to get the incoming call number. After that, I'm not getting which service to use to end the call.
using Android.App;
using Android.Content;
using Android.Provider;
using Android.Runtime;
using Android.Telecom;
using Android.Telephony;
using Android.Widget;
using Java.Lang;
using Java.Lang.Reflect;
using System;
using Exception = Java.Lang.Exception;

namespace CallManger
{
[BroadcastReceiver(Enabled = true, Exported = true)]
[IntentFilter(new[] { TelephonyManager.ActionPhoneStateChanged })]
public class IncomingCallReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
if (intent.Action == TelephonyManager.ActionPhoneStateChanged)
{
var state = intent.GetStringExtra(TelephonyManager.ExtraState);
if (state == TelephonyManager.ExtraStateRinging)
{
var number = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);

                //Reject incoming call code should go here

            }
        }
    }
Enter fullscreen mode Exit fullscreen mode

}
}

Top comments (0)