Browse files

Prevent destroying activity on runtime changes

Summary: From

> Some device configurations can change during runtime (such as screen orientation, keyboard availability, and language). When such a change occurs, Android restarts the running Activity (onDestroy() is called, followed by onCreate()). The restart behavior is designed to help your application adapt to new configurations by automatically reloading your application with alternative resources that match the new device configuration.

However, in a React Native app, there is only a single activity for the entire app, unlike a single activity per screen in Android, and resources are not specific to orientation etc. Destroying activity means reloading the entire app. Most of the time, this is not the intended behaviour, and can cause data loss for the user if the developer doesn't disable it explicitly. I'm proposing to disable it by default.
Closes #3813

Reviewed By: svcscm

Differential Revision: D2616083

Pulled By: foghina

fb-gh-sync-id: 8794e436f61581ff0bf569b1b112845cae77b688
  • Loading branch information...
satya164 authored and facebook-github-bot-6 committed Nov 4, 2015
1 parent 0c74804 commit 6c11d183604c31647264ecfa52c64143a78e3983
Showing with 2 additions and 1 deletion.
  1. +2 −1 local-cli/generator-android/templates/src/app/src/main/AndroidManifest.xml
@@ -10,7 +10,8 @@
- android:label="@string/app_name">
+ android:label="@string/app_name"
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

0 comments on commit 6c11d18

Please sign in to comment.