Browse 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 6 years ago
parent
commit
269b46d798

+ 7
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

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