You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am still fairly new to .NET MAUI and I need to rewrite a Xamarin.Forms android app to .NET MAUI. I am also using Prism framework since it has been used in Xamarin.Forms.
I have a Dialog fragment and I want to display it and initialize it when the main activity is created. In Xamarin.Forms you did this using LoadApplication(new App(new AndroidInitializer(this))); in MainActivity.cs, but I don't know what to use in .NET MAUI. I looked through the lifecycle of .NET MAUI and also this post https://learn.microsoft.com/en-us/answers/questions/1048957/platform-specific-initialization-versus-net-maui-a, but I can't find out what I should use and also don't understand it properly. AndroidInitializer is used to invoke the AndroidNotificationService where the dialog fragment resides.
As I went throuh the documentation I saw that I don't use the MainActivity.cs for inicialization and I should use dependency injection in MauiProgram.cs. I tried it but I am not sure why it isn't working and how to make it work. Everywhere I look they all have a Interface. I don't have it and just want to call this Dialog Fragment when the MainPage is created (in my case it is SignInPage)
This is the AndroidInitializer:
public class AndroidInitializer {
public MainActivity MainActivity { get; }
public AndroidInitializer() {
}
public AndroidInitializer(MainActivity mainActivity) {
MainActivity = mainActivity;
}
//using prism I connect the AndroidNotificationService to INotificationService so I can call the Notification (dialog fragment)
public void RegisterTypes(IContainerRegistry containerRegistry) {
containerRegistry.RegisterInstance(typeof(INotificationService), new AndroidNotificationService(Android.App.Application.Context, MainActivity));
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am still fairly new to .NET MAUI and I need to rewrite a Xamarin.Forms android app to .NET MAUI. I am also using Prism framework since it has been used in Xamarin.Forms.
I have a Dialog fragment and I want to display it and initialize it when the main activity is created. In Xamarin.Forms you did this using LoadApplication(new App(new AndroidInitializer(this))); in MainActivity.cs, but I don't know what to use in .NET MAUI. I looked through the lifecycle of .NET MAUI and also this post https://learn.microsoft.com/en-us/answers/questions/1048957/platform-specific-initialization-versus-net-maui-a, but I can't find out what I should use and also don't understand it properly. AndroidInitializer is used to invoke the AndroidNotificationService where the dialog fragment resides.
As I went throuh the documentation I saw that I don't use the MainActivity.cs for inicialization and I should use dependency injection in MauiProgram.cs. I tried it but I am not sure why it isn't working and how to make it work. Everywhere I look they all have a Interface. I don't have it and just want to call this Dialog Fragment when the MainPage is created (in my case it is SignInPage)
This is the AndroidInitializer:
This is MauiProgram.cs
This is PrismStartup.cs for starting the app as a prism app
This is the MainActivity.cs from Xamarin.Forms.
Beta Was this translation helpful? Give feedback.
All reactions