mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-02 19:12:40 +08:00
fix(android): application fallback for startActivity (#10062)
This commit is contained in:
@ -373,6 +373,7 @@ function initLifecycleCallbacks() {
|
||||
});
|
||||
|
||||
let activitiesStarted = 0;
|
||||
let nativescriptActivity: androidx.appcompat.app.AppCompatActivity = undefined;
|
||||
|
||||
const lifecycleCallbacks = new android.app.Application.ActivityLifecycleCallbacks(<any>{
|
||||
onActivityCreated: <any>profile('onActivityCreated', function (activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle) {
|
||||
@ -382,6 +383,10 @@ function initLifecycleCallbacks() {
|
||||
androidApp.startActivity = activity;
|
||||
}
|
||||
|
||||
if (!nativescriptActivity && (<any>activity)?.isNativeScriptActivity) {
|
||||
nativescriptActivity = activity;
|
||||
}
|
||||
|
||||
notifyActivityCreated(activity, <any>savedInstanceState, undefined);
|
||||
|
||||
if (appCommon.hasListeners(appCommon.displayedEvent)) {
|
||||
@ -394,8 +399,17 @@ function initLifecycleCallbacks() {
|
||||
androidApp.foregroundActivity = undefined;
|
||||
}
|
||||
|
||||
if (activity === nativescriptActivity) {
|
||||
nativescriptActivity = undefined;
|
||||
}
|
||||
|
||||
if (activity === androidApp.startActivity) {
|
||||
androidApp.startActivity = undefined;
|
||||
|
||||
// Fallback for start activity when it is destroyed but we have a known nativescript activity
|
||||
if (nativescriptActivity) {
|
||||
androidApp.startActivity = nativescriptActivity;
|
||||
}
|
||||
}
|
||||
|
||||
androidApp.notify(<AndroidActivityEventData>{
|
||||
|
||||
Reference in New Issue
Block a user