Advertisement
Intermediate .NET MAUI, Project Structure & App Startup

How do the native entry points bootstrap a MAUI app on Android and iOS?

Short answer

On Android, MainApplication overrides CreateMauiApp() to return MauiProgram.CreateMauiApp(), and MainActivity (a MauiAppCompatActivity) hosts it. On iOS/Mac Catalyst, AppDelegate (a MauiUIApplicationDelegate) does the same.

Save .NET MAUI mock interview
Advertisement
AModel answer
On Android, MainApplication overrides CreateMauiApp() to return MauiProgram.CreateMauiApp(), and MainActivity (a MauiAppCompatActivity) hosts it. On iOS/Mac Catalyst, AppDelegate (a MauiUIApplicationDelegate) does the same. These bridge the native app lifecycle to the shared MAUI host.
// Platforms/Android/MainApplication.cs
public class MainApplication : MauiApplication
{
    public MainApplication(IntPtr handle, JniHandleOwnership ownership)
        : base(handle, ownership) { }

    protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Real-world example
When adding a third-party SDK that needs Application.OnCreate, the developer hooks it in MainApplication before the base call.
Likely follow-ups
  • What class does MainActivity inherit? | Where is CreateMauiApp defined?
Related topics