Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Reset app start status only when Activity is finishing #4666

Open
1 of 7 tasks
entdark opened this issue Aug 3, 2023 · 0 comments
Open
1 of 7 tasks

[Android] Reset app start status only when Activity is finishing #4666

entdark opened this issue Aug 3, 2023 · 0 comments
Labels
s/needs-investigation Needs investigation by the MvvmCross team t/bug Bug type

Comments

@entdark
Copy link
Contributor

entdark commented Aug 3, 2023

馃悰 Bug Report

Currently when an Activity is about to be destroyed it is marked as tearing down and resets app start state: https://github.com/MvvmCross/MvvmCross/blob/9.1.1/MvvmCross/Platforms/Android/Views/MvxActivityViewExtensions.cs#L92
But it is not completely valid scenario on Android in case of low memory activity destroy or with option "Don't keep activities" in "Developer options" because user did not leave the app themself. So then when coming back to the app it gets correctly recreated with all the fragments and navigation stack restored. But then it navigates to the first VM again since app start status was reset and replaces all the already restored fragments and calls their VM initialization again.

Expected behavior

When coming back to the app that was destroyed by the system (not the user) and then got restored it doesn't navigate to the first VM again.
So checking only activity.IsFinishing is needed. Should be false.
If the user leaves the app intentionally by clicking Back system button or by swiping it away from Overview then activity.IsFinishing is true and then after coming back to the app it has to navigate to first VM (current behaviour for all scenarios).
Basically the correct way to fix the issue is to remove checking activity.IsDestroyed.

Reproduction steps

Enable "Don't keep activities" in "Developer options".
Open your MvvmCross app then leave it by clicking Home and come back to the app.

Configuration

Single activity app.
Not using MvxStartActivity since it's an incorrect way to start an app - you must navigate to the first VM that is an Activity.
I do call IMvxAppStart.StartAsync with condition IMvxAppStart.IsStarted (that is always false after restoration) from my single Activity and it navigates to the first VM that is a Fragment, not another Activity.

Version: 9.1.1

Platform:

  • 馃摫 iOS
  • 馃 Android
  • 馃弫 WPF
  • 馃寧 UWP
  • 馃崕 MacOS
  • 馃摵 tvOS
  • 馃悞 Xamarin.Forms
@entdark entdark added the t/bug Bug type label Aug 3, 2023
@Cheesebaron Cheesebaron added the s/needs-investigation Needs investigation by the MvvmCross team label Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s/needs-investigation Needs investigation by the MvvmCross team t/bug Bug type
Development

No branches or pull requests

2 participants