Forum Cross Platform with Xamarin

bring application from background to foreground while receiving incoming call via BroadcastReciver

Hi I'm new to Android & Xamarin development,

I have developing a application in xamarin -cross platform app for SIP calling, I have done incoming & outgoing calls. I have a problem with receiving call when app running in background. I tried to bring application to foreground while receive call.

This was code I have used,

In my MainActivity

private void registerReceiver()
{
 IncomingCallReceiver callReceiver = new IncomingCallReceiver();
 IntentFilter sipIntentFilter = new IntentFilter();
 sipIntentFilter.AddAction("com.NelsonApp.INCOMING_CALL"); 
 this.RegisterReceiver(callReceiver, sipIntentFilter);
}

and in my BroadcastReceiver

public override void OnReceive(Context context, Intent intent)
{  
          DialerCallListener listener = new DialerCallListener(); 
          SIPRegistration.call = SIPRegistration.sipManager.TakeAudioCall(intent, listener);

          Intent newIntent = new Intent(context, typeof(MainActivity));

         newIntent.AddFlags(ActivityFlags.FromBackground);
         newIntent.AddCategory(Intent.CategoryLauncher);
          context.StartActivity(newIntent);

        PlaySound pSound = new PlaySound();
        pSound .PlayRingtone(context);

      MainActivity.isIncomingCall = true;
      MessagingCenter.Send(string.Empty, "IncomingCall", value);
 }

I tried with different ActivityFlags like NewTask, SingleTop, ReorderToFront, ReceiverForeground, FromBackground, BroughtToFront but noting will bring my app to foreground. what else I want do from here. I have followed this Link . but nothing helped me... Need to add anything in manifest file? please help to fix this.

Posts

Sign In or Register to comment.