Browse Source

Null check ReactContext in onActivityResult (#1380)

Can be null if returning from another app and our activity wad destroyed in background
Guy Carmeli 7 years ago
parent
commit
1eb3bf66d3

+ 5
- 2
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java View File

@@ -88,8 +88,11 @@ public class NavigationReactGateway implements ReactGateway {
88 88
     }
89 89
 
90 90
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
91
-        Activity currentActivity = getReactInstanceManager().getCurrentReactContext().getCurrentActivity();
92
-        getReactInstanceManager().onActivityResult(currentActivity, requestCode, resultCode, data);
91
+        ReactContext reactContext = getReactInstanceManager().getCurrentReactContext();
92
+        if (reactContext != null) {
93
+            Activity currentActivity = reactContext.getCurrentActivity();
94
+            getReactInstanceManager().onActivityResult(currentActivity, requestCode, resultCode, data);
95
+        }
93 96
     }
94 97
 
95 98
     public ReactNativeHost getReactNativeHost() {