What is the difference between OnStart and App Constructor

Xamarin Forms has the following App class:

public class App : Application { public App() { // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { XAlign = TextAlignment.Center, Text = "Welcome to Xamarin Forms!" } } } }; } protected override void OnStart() { // Handle when your app starts } protected override void OnSleep() { // Handle when your app sleeps } protected override void OnResume() { // Handle when your app resumes } } 

QUESTION: What is the difference between the code that runs in the constructor and the code written in the OnStart method. Are they launched when the application starts?

see http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/app-lifecycle/ for more information.

+6
source share
1 answer

They are completely different, but the documentation is less sparse.

Designers are platform-agnostic and with the goal of creating an object (apologies if it sounds like "teach you how to suck eggs").

However, the OnStart () method maps to a platform-specific notification and corresponding value. This is a cross-platform implementation of each notification system about the launch of various system systems - this, of course, will differ between platforms, but this abstraction allows it to be processed in the same way.

+3
source

Source: https://habr.com/ru/post/983652/


All Articles