0

hey guys i'm new to xamarin forms and I've attempted a simple app that sets reminders and a part of that app is to detect end of call and generate a pop-up like in true caller.now I've tried the same code with android and loogged a message when an incoming call has been detected and it works like a charm but however the same code doesn't in xamarin forms.Droid.I've added all neccessary permissions and registered the receiver with the class name,yet I keep getting a time out exception.

is there something I'm missing?

my class which is in the droid foler:-

[BroadcastReceiver(Enabled =true,Exported = false)]
[IntentFilter(new[] { "android.Content.intent.PHONE_STATE"})]

public class IncomingCallReceiver : BroadcastReceiver
{


    public override void OnReceive(Context context, Intent intent)
    {
        try
        {
            Console.WriteLine("Receiver start");
            // Toast.MakeText(context, " Receiver start ",  ToastLength.Long).Show();
        }
        catch (Exception e)
        {
            Console.WriteLine("Receiver start ex " + e.StackTrace);
        }

}
}

android manifest file:-

**<application android:label="IncomingCall.Android">
<receiver android:name="com.companyname.IncomingCall.IncomingCallReceiver">
  <intent-filter>
    <action android:name="android.intent.action.PHONE_STATE"/>
  </intent-filter>
</receiver>

the MainActivity.cs file:-

the below two methods have been declared in my MainActivity.cs

  protected override void OnResume()
        {
            base.OnResume();
            RegisterReceiver(receiver, new IntentFilter("com.companyname.IncomingCall"));
            // Code omitted for clarity

        }
        protected override void  OnPause()
        {
            UnregisterReceiver(receiver);
            // Code omitted for clarity
            base.OnPause();
        }

can someone kindly point out where I'm going wrong with this?

  • https://stackoverflow.com/questions/44236219/how-to-get-event-when-i-am-answering-outgoing-call/44238240#44238240 – SushiHangover Sep 01 '18 at 06:24
  • @SushiHangover thank you soo much it finally!!!! worked i hadn't included the receiver [BroadcastReceiver(Enabled =true,Exported = false)] and after i changed it to this [BroadcastReceiver(Name = "com.companyname.IncomingCall.IncomingCallReceiver")] it worked. – Russell Fernandes Sep 01 '18 at 07:40
  • Glad to hear it, happy coding... – SushiHangover Sep 01 '18 at 07:45

0 Answers0