From 90b8718138fc6e67e2141d9b77017b3d96e50d51 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Sat, 18 Sep 2021 17:27:21 -0300 Subject: [PATCH] fix(android): only attach if activity is CREATED (#9552) --- packages/core/ui/frame/index.android.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index 200083ea8..177d2b4c5 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -144,8 +144,8 @@ export class Frame extends FrameBase { // _onAttachedToWindow called from OS again after it was detach // still happens with androidx.fragment:1.3.2 - const activity = androidApplication.foregroundActivity || androidApplication.startActivity; - if ((this._manager && this._manager.isDestroyed()) || !activity.getLifecycle?.().getCurrentState().isAtLeast(androidx.lifecycle.Lifecycle.State.STARTED)) { + const lifecycleState = (androidApplication.foregroundActivity?.getLifecycle?.() || androidApplication.startActivity?.getLifecycle?.())?.getCurrentState() || androidx.lifecycle.Lifecycle.State.CREATED; + if ((this._manager && this._manager.isDestroyed()) || !lifecycleState.isAtLeast(androidx.lifecycle.Lifecycle.State.CREATED)) { return; }