Skip to content

fix(android/application): open windows after the original activity finishes - #11552

Open
rafaelaugustos wants to merge 1 commit into
NativeScript:mainfrom
rafaelaugustos:fix/android-open-window-activity
Open

rafaelaugustos wants to merge 1 commit into
NativeScript:mainfrom
rafaelaugustos:fix/android-open-window-activity

Conversation

@rafaelaugustos

@rafaelaugustos rafaelaugustos commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Checklist

What is the current behavior?

After the original Android Activity finishes, startActivity can be cleared while a secondary NativeWindow remains usable. openWindow() then targets the hard-coded org.nativescript.NativeScriptActivity, which may not be declared in the manifest, and throws ActivityNotFoundException.

What is the new behavior?

Resolve the target from a live NativeScript Activity: the original Activity, the foreground Activity, or an attached surviving window. Exclude finishing/destroyed Activities, windows whose native surfaces are gone, and SDK Activities without the NativeScript marker. If none remains, use the application's configured launch component; report a clear error when it has no launch component instead of starting an undeclared class.

The existing window flags and payload delivery are preserved. This changes Android target selection only; there is no public API change.

Closes #11526.

Validation

  • Added 10 regression cases for surviving windows, original/foreground Activity selection, SDK Activities, finishing/destroyed Activities, detached surfaces, configured launch components and the missing-launcher error. Against the original implementation, 9 of these cases fail.
  • npx nx run core:test: 544 passed, 1 skipped, across 42 test files.
  • npx nx run core:build: passed, before and after the fix.
  • npx nx format:write --files=packages/core/application/application.android.ts,packages/core/application/open-window.android.spec.ts,packages/core/vitest.setup.ts: passed.
  • Android 16 / API 36 arm64 emulator, NativeScript Android runtime 9.1.1, Core built from 3224f1b, com.tns.NativeScriptActivity, launchMode="standard": reproduced using an isolated native app with a window content resolver, without the router.

The native app opens a second window, finishes the original Activity, then requests another window from the survivor after activityDestroyed:

Before the final open request (both builds):
  startActivity=false, foregroundActivity=true, windows=1

Original Core:
  ActivityNotFoundException:
  {org.nativescript.openwindow11526/org.nativescript.NativeScriptActivity}

Patched Core:
  {"ok":true,"windows":2,"originalDestroyed":true,
   "payload":"after-primary-finished","flags":403177472}

The complete native automated app suite and an iOS simulator run were not executed locally. The native before/after check above and the full Core unit suite were executed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android openWindow uses an undeclared Activity class after the original Activity finishes

1 participant