Override the default outgoing call screen

I am trying to override the default outgoing dialer app and replace it with my activity. My receiver is already working for me and correctly responds to an outgoing call, but I can’t figure out how to prohibit the default readings and supplement it with my custom layout.

When I return to my custom application, I see that it has loaded my dialer layout. It does not replace or display the default dialer number. Any ideas?

Primary activity:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace minuteSaver
{
    [Activity (Label = "minuteSaver", MainLauncher = true)]
    public class MainActivity : Activity
    {
        private icCall _receiver;
        int count = 1;

        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            #region Code for using delegate to access class
            var filter = new IntentFilter();
            filter.AddAction(Intent.ActionNewOutgoingCall);
            var receiver = new icCall { OnReceiveAction = () => {
                        Toast notifyUser = Toast.MakeText(this, "test", ToastLength.Long);
                    if (filter.GetAction(0) == Intent.ActionNewOutgoingCall)
                    {
                        notifyUser.Show();
                        var second = new Intent(this, typeof(mdCall));
                        second.AddFlags(ActivityFlags.ClearTop);
                        second.AddFlags(ActivityFlags.NewTask);
                        StartActivity(second);
                    }
                }};
            RegisterReceiver(receiver, filter);

            #endregion
            Console.WriteLine ("Receiver registered.");
        }
    }
}

BroadcastReceiver Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Telephony;


namespace minuteSaver
{
    [BroadcastReceiver (Enabled = true, Exported = false)]
    [IntentFilter(new string[] { "android.intent.action.NEW_OUTGOING_CALL" }, Priority = (int)IntentFilterPriority.HighPriority)]
    class icCall:BroadcastReceiver

    {
        public Action OnReceiveAction;
        public override void OnReceive (Context context, Intent intent)
        {
            if (OnReceiveAction != null) 
            {
                OnReceiveAction.Invoke ();
                InvokeAbortBroadcast ();
            }
            Toast notifyUser = Toast.MakeText(context, "test", ToastLength.Short);
            if (intent.Action == Intent.ActionNewOutgoingCall)
            {
                InvokeAbortBroadcast ();
            Wait (900);
                Intent i = new Intent (context, typeof(mdCall));
                    i.AddFlags(ActivityFlags.ClearTop);
                i.AddFlags(ActivityFlags.NewTask);
                context.StartActivity (i);

                    notifyUser.Show();
                Console.WriteLine ("Debug: Outgoing call detected");
            }
        }
    }
}
+4
source share

Source: https://habr.com/ru/post/1539145/


All Articles