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 app always restarts on clicking the app icon #27370

Closed
makarkotlov opened this issue Nov 29, 2019 · 1 comment
Closed

React Native app always restarts on clicking the app icon #27370

makarkotlov opened this issue Nov 29, 2019 · 1 comment
Labels
Bug Resolution: Locked This issue was locked by the bot.

Comments

@makarkotlov
Copy link

makarkotlov commented Nov 29, 2019

React Native app always restarts on clicking the app icon

ezgif com-video-to-gif

React Native version:
System:
OS: macOS 10.15.1
CPU: (4) x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 323.82 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.12.0 - /usr/local/bin/node
npm: 6.13.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 21, 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-21 | Intel x86 Atom_64, android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5977832
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4
npmGlobalPackages:
react-native-cli: 2.0.1

Steps To Reproduce

  1. Click the app icon
  2. Pause the app by clicking on "Home" button
  3. Click the app icon again

Describe what you expected to happen:

App is not restarts by clicking on app icon if app is already started

P.S. I think this answer could help https://stackoverflow.com/questions/17545924/android-app-restarts-when-opened-by-clicking-app-icon/33260878

@makarkotlov
Copy link
Author

I solved it by adding android:launchMode="singleTask" to the activity in AndroidManifest.xml

facebook-github-bot pushed a commit that referenced this issue Dec 2, 2019
Summary:
Most RN apps have single activity, and developers expect to resume application from background when app icon pressed. But Android default configuration creates a new activity instance, which confuses developers, see #27370 and #27368.

This PR changes template manifest so that when app icon pressed, background app will resume instead of creating a new activity, therefore match developers expectations. Also it's required to make Linking work.

## Changelog

[Android] [Changed] - MainActivity launchMode is singleTask
Pull Request resolved: #27373

Test Plan: RNTester will resume background app, instead of creating a new instance when app icon pressed

Differential Revision: D18766373

Pulled By: mdvacca

fbshipit-source-id: 697e9c5bf92ec958de265b060dffb50f7b74d157
@facebook facebook locked as resolved and limited conversation to collaborators Oct 2, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

2 participants