question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(Android) App component reconstructed on split screen resize

See original GitHub issue

React Native version:

  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 405.22 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.14.1 - /usr/local/bin/node
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 26.0.2, 28.0.3, 29.0.0
        System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.5 => 0.59.5 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Steps To Reproduce

  1. Create a new project via react-native init AppName
  2. Add constructor with a console.log in the default app component (in App.js)
  3. Run the app

Expected behaviour

Switch to split-screen view or pop up view and resize the app window and continue to be able to use the app where it left off.

Actual behaviour

When switching to split screen or pop up view the app component is discarded and reconstructed, meaning the state of the app completely reset. The same thing happens when the app window is resized in this state.

I placed console.log at the top of both index.js and App.js (outside of any class or function) and inside the constructor the the default app class. The logs that were placed at the top of the two files were only called when the app was started while the one in the App constructor was called every time the app window was resized and the state was lost.

This tells me that the JS environment survives, but RN just reinitializes the app for whatever reason.

It seems to be the same as this issue that went stale and was never resolved.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

8reactions
phunguyenmurculcommented, Jul 26, 2019

This is a note from android developer:

To handle all Multi-Window related configuration changes use both “screenLayout” and “smallestScreenSize”. Multi-Window is supported in Android 7.0 (API level 24) or higher.

You should add “screenLayout|smallestScreenSize” into “android:configChanges” to make it works

0reactions
Jadeon-FPMcommented, Jul 26, 2019

This is a note from android developer:

To handle all Multi-Window related configuration changes use both “screenLayout” and “smallestScreenSize”. Multi-Window is supported in Android 7.0 (API level 24) or higher.

You should add “screenLayout|smallestScreenSize” into “android:configChanges” to make it works

This worked for me actually! I’m surprised I couldn’t find this listed anywhere. It should almost be included be default when the android project is generated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi-window support - Android Developers
Multi -window mode enables multiple apps to share the same screen simultaneously. Apps can be side by side or one above the other...
Read more >
5 tips for preparing for Multi-Window in Android N | by Ian Lake
Multi -window takes advantage of the resource system by adjusting the configuration based on the size of your window — screen size is...
Read more >
Activity doesn't restart on orientation change when window ...
The activity restarts properly while changing orientation when the window size is 1/2 or 1/3 the display size in multi window mode. I...
Read more >
Split screen feature doesn't work as it use to [210345474]
Android11 would let a user switch apps in split screen mode to whatever they wanted and access the home screen and even an...
Read more >
Automatically Scaling Android Apps For Multiple Screens
In order to scale this to a much different screen size effectively, the buttons must be resized without affecting their layout or aspect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found