From de4cb7d40318094543f2a160c88e8013772d9f7d Mon Sep 17 00:00:00 2001 From: Peter Lai Date: Mon, 9 Nov 2015 14:55:16 -0800 Subject: [PATCH] Fix crash when double launching activity Reviewed By: AaaChiuuu Differential Revision: D2633573 fb-gh-sync-id: c47bec903d54c12f4d9e576ad1aaf16d4bd68f30 --- .../java/com/facebook/react/bridge/ReactContext.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index 47486d3c2..ee669462a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -227,10 +227,14 @@ public class ReactContext extends ContextWrapper { /** * Same as {@link Activity#startActivityForResult(Intent, int)}, this just redirects the call to - * the current activity. + * the current activity. Returns whether the activity was started, as this might fail if this + * was called before the context is in the right state. */ - public void startActivityForResult(Intent intent, int code, Bundle bundle) { - Assertions.assertNotNull(mCurrentActivity); + public boolean startActivityForResult(Intent intent, int code, Bundle bundle) { + if (mCurrentActivity == null) { + return false; + } mCurrentActivity.startActivityForResult(intent, code, bundle); + return true; } }