Skip to content

fix: add MAIN/LAUNCHER flags to Android launcher activity resolver#115

Merged
thymikee merged 2 commits into
callstack:mainfrom
EarthXP:fix/android-launcher-activity-resolution
Feb 24, 2026
Merged

fix: add MAIN/LAUNCHER flags to Android launcher activity resolver#115
thymikee merged 2 commits into
callstack:mainfrom
EarthXP:fix/android-launcher-activity-resolution

Conversation

@EarthXP
Copy link
Copy Markdown
Contributor

@EarthXP EarthXP commented Feb 24, 2026

Summary

  • Add -a android.intent.action.MAIN -c android.intent.category.LAUNCHER to the resolve-activity fallback command in resolveAndroidLaunchComponent()
  • The resolver was missing these intent flags, causing it to resolve the wrong activity on multi-entry apps (e.g. Microsoft Outlook)
  • E2E testing uncovered a deeper issue: am start -W -p <package> exits with code 0 even when it fails to resolve the activity, printing Error: Activity not started, unable to resolve Intent to stdout. The original try/catch never triggered the fallback because runCmd did not throw on exit code 0. Added isAmStartError() to detect this silent failure and correctly fall through to the component-based fallback.
  • Add unit tests for resolver parsing, error detection, and launch command construction

Changes

Commit 1: Fix resolve-activity flags

resolveAndroidLaunchComponent() now passes -a android.intent.action.MAIN -c android.intent.category.LAUNCHER to cmd package resolve-activity, ensuring the correct launcher activity is resolved for multi-entry apps.

Commit 2: Detect am start silent failures

  • Replace try/catch with allowFailure: true + stdout/stderr inspection via isAmStartError()
  • am start -p returning exit code 0 with Error: Activity not started in stdout now correctly triggers the component-based fallback
  • Verified end-to-end on a physical Android device with Microsoft Outlook

Test plan

  • parseAndroidLaunchComponent correctly parses multi-entry resolve output
  • isAmStartError detects am start failure messages in stdout
  • isAmStartError returns false for successful launches
  • Fallback resolve-activity command includes -a MAIN -c LAUNCHER flags
  • Default launch path still uses -p <package> (system-driven resolution)
  • E2E: agent-device open "com.microsoft.office.outlook" --platform android launches Outlook without --activity flag on physical device

EarthXP and others added 2 commits February 24, 2026 12:41
The `resolve-activity` fallback command was missing `-a android.intent.action.MAIN`
and `-c android.intent.category.LAUNCHER`, causing it to resolve the wrong activity
on multi-entry apps like Microsoft Outlook. This adds the correct intent flags so
the resolver consistently returns the launcher activity.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
am start -p <package> can exit 0 while printing "Error: Activity not
started" to stdout.  The previous try/catch never entered the fallback
because runCmd did not throw.  Now we check the output for error
indicators via isAmStartError() and proceed to the resolve-activity
fallback when the primary launch silently fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@EarthXP
Copy link
Copy Markdown
Contributor Author

EarthXP commented Feb 24, 2026

Have tested in my Android phone (Android 12) which didn't work before, now it works with the fix.

@thymikee thymikee merged commit 0041dee into callstack:main Feb 24, 2026
5 of 6 checks passed
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.

2 participants