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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Avoid OnDestroy lifecycle event firing twice #14799

Merged
merged 1 commit into from Apr 28, 2023
Merged

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Apr 27, 2023

Description of Change

Avoid Android OnDestroy lifecycle event firing twice.

[0:] Lifecycle event: OnBackPressed
[0:] Lifecycle event: OnBackPressed (shortcut)
[0:] Lifecycle event: OnPause
[DOTNET] OnStopped
[0:] Lifecycle event: OnStop
[0:] Lifecycle event: OnSaveInstanceState
[0:] Lifecycle event: OnSaveInstanceState (shortcut)
[0:] OnDisappearing: Maui.Controls.Sample.Pages.MainPage
[DOTNET] OnDestroying
[0:] Lifecycle event: OnDestroy

Issues Fixed

Fixes #8541

@jsuarezruiz jsuarezruiz added t/bug Something isn't working platform/android 🤖 area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events labels Apr 27, 2023
{
base.OnDestroy();

MauiApplication.Current?.Services?.InvokeLifecycleEvents<AndroidLifecycle.OnDestroy>(del => del(this));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already firing here

public void OnActivityDestroyed(Activity activity) =>
Current.Services?.InvokeLifecycleEvents<AndroidLifecycle.OnDestroy>(del => del(activity));

@mattleibow
Copy link
Member

/rebase

@mattleibow mattleibow merged commit 8f51c71 into main Apr 28, 2023
28 checks passed
@mattleibow mattleibow deleted the fix-8541 branch April 28, 2023 08:00
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] OnDestroy is currently firing twice
2 participants