There are three lifecycle method of xamarin.forms app development.
OnStart,Onsleep,OnResume.
OnStart:-called when the application start.
OnSleep:-Called each time when application goes to the background.
OnResume:-Called when the application is resumed,after being sent to the background.
Note:-There is no method for application termination.expect few cases(e.g.:-Not a Crash)application termination will happen from the OnSleep state, without any additional notifications to your code.
To observe when these methods are called, implement a WriteLine call in each (as shown below) and test on each platform.
protected override void OnStart()
{
Debug.WriteLine ("OnStart");
}
protected override void OnSleep()
{
Debug.WriteLine ("OnSleep");
}
protected override void OnResume()
{
Debug.WriteLine ("OnResume");
}
Note:-When updating older Xamarin.Forms applications (eg. create with Xamarin.Forms 1.3 or older), ensure that the Android main activity includes ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation in the [Activity()] attribute. If this is not present you will observe the OnStart method gets called on rotation as well as when the application first starts. This attribute is automatically included in the current Xamarin.Forms app templates.
@ifour Techno Lab Pvt. Ltd.