App Lifecycle event OnResume called more than once.
See original GitHub issueDescription
The application lifecycle event OnResume is called more than once when an application is minimised/stopped and then resumed.
Steps to Reproduce
- Create a new project using the “.NET MAUI App” template.
- Edit App.xaml.cs
- Add within the partial class the following:
private int ResumeCount = 0;
- Add an override method for OnResume:
protected override void OnResume()
{
base.OnResume();
ResumeCount++;
System.Diagnostics.Debug.WriteLine("{0}: Restarted {1}", DateTimeOffset.UtcNow, ResumeCount);
}
- Build and launch in debug (Windows Machine):
- Minimise the app
- Restore the app
- In the debug output window, there will be 2 debug statements indicating: Restarted 1 Restarted 2
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows, I was not able test on other platforms
Affected platform versions
Android 21.0, Windows 10.0.17763.0
Did you find any workaround?
No response
Relevant log output
09/06/2022 13:29:24 +00:00: Restarted 1
09/06/2022 13:29:24 +00:00: Restarted 2
VS bug #1778056
Depends on
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Why is my onResume being called twice?
My issue with onResume being caused twice was because onPause was somehow being called after the activity was created.. something was ...
Read more >The activity lifecycle
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial...
Read more >App lifecycle - .NET MAUI
NET MAUI raises cross-platform lifecycle events when an app transitions between its different execution states.
Read more >Activity Lifecycle
onResume() is called at the start of the active lifetime; more specifically, it is called at the start of the active lifetime; more...
Read more >Jetpack Compose — Making Composable lifecycle-aware
We want to refetch our App data when the user comes from background to ... Then on OnResume lifecycle event it will call...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
AFAICT this is a bug with the WinAppSdk firing the
OnActivated
event twicehttps://github.com/microsoft/microsoft-ui-xaml/issues/7343
I have checked the Platforms, specifically for the Windows platform, and any additional builder wire-ups, and there is nothing that I can find that the default template provides that could account for multiple invokes.