Open tranb3r opened 9 months ago
This happens quite frequently on Pixel devices, as activities get temporarily closed for performance reasons (happens often overnight). If this happens, no app method is called for proper app recovery.
Probably there are some other recovery issues as well if activities are restored by OS. For instance, the Mopups PopupStack contains visible popups although the activity's DecorView is empty (= popup windows are gone).
.net MAUI 8.0.3, Android 13 & 14
Our workaround is currently to call App.Current.Quit() in MainActivity's OnDestroy. Thus, we force a clean restart of the application including OnStart();
Our workaround is currently to call App.Current.Quit() in MainActivity's OnDestroy. Thus, we force a clean restart of the application including OnStart();
This is also what I'm doing.
Verified this issue with Visual Studio 17.10.0 Preview 3 (8.0.20 & 8.0.0-rc.2.9530),I can repro it.
I'm guessing the life cycle events you want are on the window
Try creating your own window type https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/windows?view=net-maui-8.0#create-a-window
And see about override the lifecycle methods on there
We are also experiencing a problem when Android OS shuts down the activity. When it happens after the user has had the app in background for an extensive amount of time (6h to 20 days) then The MAUI App.cs still remembers the MainPage that was used last time, and does not reconstruct none oof the pages in current navigation stack. Is this intended and if it is, does this mean we need to manually restart all the platform dependent code when new Activity is created?
Description
When starting a Maui Application, the App constructor is called first, then the OnStart method is called. But if Android kills the Activity, then no method from App is called when relaunching the application. I would expect either the constructor or OnStart or OnResume to be called.
More details about events/methods being called during the lifecycle of an app (logs added to my repro):
Steps to Reproduce
Link to public reproduction project repository
https://github.com/tranb3r/Issues/tree/main/MauiAppLifecycleIssue
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 14
Did you find any workaround?
No response
Relevant log output
No response