From 2c480bcebc2569f7617faa10a49b1271df43c51a Mon Sep 17 00:00:00 2001 From: Kirill Zyusko Date: Sat, 11 Feb 2023 05:24:31 +0400 Subject: [PATCH] fix: restart activity to avoid crashes (#116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📜 Description Don't persist activity state and always restart it. ## 💡 Motivation and Context I don't know why I didn't make it before, but it needs to be added in order to reduce amount of occasional crashes. You can read a great explanation [here](https://github.com/software-mansion/react-native-screens#android) on why it's needed. ## 📢 Changelog ### Android - added `super.onCreate(null)` in `MainActivity` for example apps; ## 🤔 How Has This Been Tested? Tested manually on emulators. ## 📝 Checklist - [x] CI successfully passed --- .../com/keyboardcontrollerfabricexample/MainActivity.java | 7 +++++++ .../reactnativekeyboardcontroller/MainActivity.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/FabricExample/android/app/src/main/java/com/keyboardcontrollerfabricexample/MainActivity.java b/FabricExample/android/app/src/main/java/com/keyboardcontrollerfabricexample/MainActivity.java index cd9db40da..75208a31d 100644 --- a/FabricExample/android/app/src/main/java/com/keyboardcontrollerfabricexample/MainActivity.java +++ b/FabricExample/android/app/src/main/java/com/keyboardcontrollerfabricexample/MainActivity.java @@ -1,5 +1,7 @@ package com.keyboardcontrollerfabricexample; +import android.os.Bundle; + import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; import com.facebook.react.ReactRootView; @@ -45,4 +47,9 @@ protected boolean isConcurrentRootEnabled() { return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; } } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(null); + } } diff --git a/example/android/app/src/main/java/com/example/reactnativekeyboardcontroller/MainActivity.java b/example/android/app/src/main/java/com/example/reactnativekeyboardcontroller/MainActivity.java index 4459331c6..a01a768c4 100644 --- a/example/android/app/src/main/java/com/example/reactnativekeyboardcontroller/MainActivity.java +++ b/example/android/app/src/main/java/com/example/reactnativekeyboardcontroller/MainActivity.java @@ -47,6 +47,6 @@ protected boolean isConcurrentRootEnabled() { @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + super.onCreate(null); } }