mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
fix(android): prevent possible crash when app goes to background
This commit is contained in:
@ -20,6 +20,7 @@ import { CSSUtils } from '../../css/system-classes';
|
||||
import { Device } from '../../platform';
|
||||
import { profile } from '../../profiling';
|
||||
import { ExpandedEntry } from './fragment.transitions.android';
|
||||
import { android as androidApplication } from '../../application';
|
||||
|
||||
export * from './frame-common';
|
||||
|
||||
@ -146,8 +147,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;
|
||||
}
|
||||
|
||||
@ -334,8 +336,6 @@ export class Frame extends FrameBase {
|
||||
|
||||
// If we had real navigation process queue.
|
||||
this._processNavigationQueue(entry.resolvedPage);
|
||||
|
||||
|
||||
} else {
|
||||
// Otherwise currentPage was recreated so this wasn't real navigation.
|
||||
// Continue with next item in the queue.
|
||||
|
Reference in New Issue
Block a user