Parcourir la source

Hack to fix when app is stuck on the splash screen. (#3688)

When the navigation activity is killed/restarted by the system, onCreate launches the SplashActivity and kills itself. The new SplashActivity starts context initialization but that is broken in between by the onDestroy of the NavigationActivity we just killed. This fix adds a boolean to disable destruction of js in this case.
Basit Ali il y a 6 ans
Parent
révision
269b46d798

+ 7
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java Voir le fichier

@@ -63,12 +63,15 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
63 63
     @Nullable
64 64
     private PermissionListener mPermissionListener;
65 65
 
66
+    boolean killedBySystem = false;
67
+
66 68
     @Override
67 69
     protected void onCreate(Bundle savedInstanceState) {
68 70
         super.onCreate(savedInstanceState);
69 71
         if (!NavigationApplication.instance.getReactGateway().hasStartedCreatingContext() ||
70 72
                 getIntent() == null ||
71 73
                 getIntent().getBundleExtra("ACTIVITY_PARAMS_BUNDLE") == null) {
74
+            killedBySystem = true;
72 75
             SplashActivity.start(this);
73 76
             finish();
74 77
             return;
@@ -196,6 +199,10 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
196 199
     }
197 200
 
198 201
     private void destroyJsIfNeeded() {
202
+        if ( killedBySystem ) {
203
+            return;
204
+        }
205
+
199 206
         if (currentActivity == null || currentActivity.isFinishing()) {
200 207
             getReactGateway().onDestroyApp(this);
201 208
         }