Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native run-android works weirdly with standard launch mode #1907

Closed
rlawjd5 opened this issue Apr 13, 2023 · 2 comments · Fixed by #1916
Closed

react-native run-android works weirdly with standard launch mode #1907

rlawjd5 opened this issue Apr 13, 2023 · 2 comments · Fixed by #1916

Comments

@rlawjd5
Copy link

rlawjd5 commented Apr 13, 2023

Environment

System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.96 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.14.2 - ~/.asdf/installs/nodejs/16.14.2/bin/node
Yarn: Not Found
npm: 8.5.0 - ~/.asdf/plugins/nodejs/shims/npm
Watchman: 2023.03.06.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /Users/junghwan/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9619390
Xcode: 14.3/14E222b - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.6 => 0.71.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Description

In my app, another activity is started by RN native modules like facebook/react-native#30726

I want to keep Activity Stack, when user press home button and re-open the app via app icon.
So, I changed the launchMode of MainActivity to standard from singleTask.
And then, activity stacks are kept as expected.

Installing APK or running via android studio, It works well without the problem.
But, multiple MainActivity are overlapped with react-native run-android.
It is not reproduced after kill the app from task manager.

For simple testing, I used initial template without implementing to start other activity.
https://user-images.githubusercontent.com/53458426/231677848-a44468e7-7518-4853-8034-57a750ffd6d3.mov

Reproducible Demo

  1. Create project with npx react-native@latest init TestProject
  2. Change launchMode of MainActivity to standard from singleTask
  3. run metro with npm start
  4. run android app with npx react-native run-android
  5. Click Home button and Click App icon multiple times
  6. Press Back button and see Multiple MainActivity are overlapped.
  7. Kill the app from task manager and repeat Step 5
  8. Press Back button and see only one MainActivity are exist.
@rlawjd5
Copy link
Author

rlawjd5 commented Apr 13, 2023

Current script for launching the app is shell am start -n package/activity
But, Intent started from Home screen has options act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]

image
image

I'm not sure about the principle behind it, but it seems that the two differences are causing the problem.
I launched app with shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n package/activity then problem is not reproduced.

How about adding flags -a android.intent.action.MAIN -c android.intent.category.LAUNCHER to current script?

@cortinico
Copy link
Member

I launched app with shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n package/activity then problem is not reproduced.

Thanks for reporting. This is a bug and should be fixed in the cli-platform-android package as we should align our adb launch parameters to the one used by Android Studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants