I am developing a Xamarin Forms app using Visual studio.
I want to test this scenario:
How to achieve this? Mainly I would like to test these events - Suspended, Shutdown and Resume.
Can someone please help me out?
It has to do with Xamarin. Forms Lifecycle Methods : Put your breakpoints in following methods inside the App.xaml.cs class:
OnStart - Called when the application starts.
OnSleep - Called each time the application goes to the background.
OnResume - Called when the application is resumed, after being sent to the background.
Note that there is no method for application termination. Under normal circumstances (ie. 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");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.