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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: remove dependency on SplashScreen. Fix startup issues. #3376
Conversation
…fecycle from within the base activity.
Hey @softlion does this assume now that all Android applications will have an application class? I think the current implementation allows for the scenario where there is no application class, and thus the splash screen initiates the Mvx startup. |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry I wasn't very clear with my previous comment - I meant that this would mean that all developers would have to explicitly include an application class in their Android project which is a change in behaviour for Mvx. I think this might make things simpler and definitely like the implementation you've added. |
MvvmCross.Android.Support/V7.AppCompat/StartupLifecycleCallback.cs
Outdated
Show resolved
Hide resolved
Wouldn't it be possible to detect the splashscreen based on the
|
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
… + NDLC in NLog 4.6
* Use license expression for nuget package * Add license to package
* Add xml attribute to optimize importing of classes, controls and effects into XAML code * Move attributes * Change file * Rename file
This comment was marked as abuse.
This comment was marked as abuse.
This PR is actually pretty cool. I think we should get it into MvvmCross 7.0.0. Sorry for dragging this out @softlion |
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
Are there any plans to migrate this to android x and merge? It would help a lot since now we're forced to use an Activity for initialization (in our case, we follow the single activity pattern so we end up needing two activities: the splash and the one where all the navigation happens) |
I branched off of develop and hand copied the changes @softlion made. MvvmCross doesn't build in macOS so I don't have a way to test if the changes carried over. Maybe you'd like to take a look at what I did and force push? I'd like to see this effort continue! https://github.com/Hackmodford/MvvmCross/tree/android-no-splashscreen-copy |
@softlion How does this work with no splash screen? I tried modifying the playground to not use a splash screen and I seem to get two instances of the root activity. Also is the original MvxSplashScreenActivity supposed to still be an option? Because I noticed it crashes if you start the app, then immediately press the back button. |
@Hackmodford the approach here with having to create Application class is fine. However, coming in MAUI and I've also been thinking about it, we would need to provide an AppHost. So this means that taking a dependency on Microsoft.Extensions.DependencyInjection and creating our own App host would very much obsolete this work and also obsolete how MvvmCross starts up and registers all its dependencies currently. So while this code might work, I was thinking about changing everything. Just need to find some time to spend on this. |
This comment was marked as abuse.
This comment was marked as abuse.
@Cheesebaron Does the AppHost comment apply if we were building a native app instead of a MAUI (Forms) type app? |
Recently I've exploring some MAUI code and I think we can have similar IStartup approach in Mvx. What we need is dependency of these three libs: MAUI.Core, MAUI.Essentials and Microsoft.Maui.Graphics. If we will add them we can stay closer to modern .NET developing. Btw those libs can be built against 'old' pre-6 Xamarin targets and netStd. |
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Remove dependency on SplashScreen on Android.
Also remove startup lifecycle from within the base activity.
Also fix all android lifecycle problems.
Also fix static android shortcuts that were not working.
Also fix the usage of AppCenter Distribute, where the first launch could crash the app after coming back from appcenter screen.
An Android app must have a SplashScreenActivity derived from MvxSplashScreenAppCompatActivity.
Also all Activities implements the startup code.
🆕 What is the new behavior (if this is a feature change)?
SplashScreenActivity can be of any kind. Especially it can have no layout at all, when its layout is being defined by it's style, to get the fastest possible startup time.
💥 Does this PR introduce a breaking change?
Yes (impact: low): the handling of activity startup is done inside the StartupLifecycleCallback class only, and no more on all the activities that derived from MvxActivity.
Yes (impact: moderate): the app must have an Application class, which results in all static variables and variables linked to the application class behind held in memory, saved and restored. If memory management is not carefully crafted, it will quickly lead to out of memory exceptions.
🐛 Recommendations for testing
Android playground updated
📝 Links to relevant issues/docs
🤔 Checklist before submitting