mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(android): prevent potential crash when app goes to background (#9347)
This commit is contained in:
committed by
Nathan Walker
parent
a76815b81e
commit
e7b30af394
@@ -19,6 +19,7 @@ import { Builder } from '../builder';
|
||||
import { CSSUtils } from '../../css/system-classes';
|
||||
import { Device } from '../../platform';
|
||||
import { profile } from '../../profiling';
|
||||
import { android as androidApplication } from '../../application';
|
||||
|
||||
export * from './frame-common';
|
||||
|
||||
@@ -143,8 +144,9 @@ export class Frame extends FrameBase {
|
||||
super._onAttachedToWindow();
|
||||
|
||||
// _onAttachedToWindow called from OS again after it was detach
|
||||
// TODO: Consider testing and removing it when update to androidx.fragment:1.2.0
|
||||
if (this._manager && this._manager.isDestroyed()) {
|
||||
// still happens with androidx.fragment:1.3.2
|
||||
const activity = androidApplication.foregroundActivity;
|
||||
if ((this._manager && this._manager.isDestroyed()) || !activity.getLifecycle().getCurrentState().isAtLeast(androidx.lifecycle.Lifecycle.State.STARTED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user