locked
How to access Xamarin.Forms.Application object from the MainActivity RRS feed

  • Question

  • User386626 posted

    Hello,

    I need to send a message to the App object which was subscribed.

    That App object is of Xamarin.Forms.Application class..... from Activity, in .Android project, I need to send a message to it, something like:

    global::Xamarin.Forms.MessagingCenter.Send(this.Application, "AddItem", new string[]{ info.Code.ToString(), info.Description });

    In this case, this.Application is not of type Xamarin.Forms.Application, so it did not work.

    How can I solve this? I have spent several hours trying to find the solution in search engines but no avail.

    Regards

    Jaime

    Friday, June 14, 2019 11:42 PM

All replies

  • User382921 posted

    Using dependencies refer to link: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/enterprise-application-patterns/dependency-injection

    Saturday, June 15, 2019 11:38 AM
  • User74518 posted

    Xamarin.Forms.Application.Current

    Saturday, June 22, 2019 1:42 AM
  • User220108 posted

    You can try like below,

    var XFAppInstance = new App(); LoadApplication(XFAppInstance); MessagingCenter.Send(XFAppInstance, "AddItem", new string[] { info.Code.ToString(), info.Description });

    Saturday, June 22, 2019 6:38 AM