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 c43a23ac9..f83c2ba56 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -162,7 +162,11 @@ public class ReactContext extends ContextWrapper { runOnUiQueueThread(new Runnable() { @Override public void run() { - listener.onHostResume(); + try { + listener.onHostResume(); + } catch (RuntimeException e) { + handleException(e); + } } }); break; @@ -205,9 +209,12 @@ public class ReactContext extends ContextWrapper { UiThreadUtil.assertOnUiThread(); mLifecycleState = LifecycleState.RESUMED; mCurrentActivity = new WeakReference(activity); - mLifecycleState = LifecycleState.RESUMED; for (LifecycleEventListener listener : mLifecycleEventListeners) { - listener.onHostResume(); + try { + listener.onHostResume(); + } catch (RuntimeException e) { + handleException(e); + } } } @@ -215,7 +222,11 @@ public class ReactContext extends ContextWrapper { UiThreadUtil.assertOnUiThread(); mCurrentActivity = new WeakReference(activity); for (ActivityEventListener listener : mActivityEventListeners) { - listener.onNewIntent(intent); + try { + listener.onNewIntent(intent); + } catch (RuntimeException e) { + handleException(e); + } } } @@ -226,7 +237,11 @@ public class ReactContext extends ContextWrapper { UiThreadUtil.assertOnUiThread(); mLifecycleState = LifecycleState.BEFORE_RESUME; for (LifecycleEventListener listener : mLifecycleEventListeners) { - listener.onHostPause(); + try { + listener.onHostPause(); + } catch (RuntimeException e) { + handleException(e); + } } } @@ -237,7 +252,11 @@ public class ReactContext extends ContextWrapper { UiThreadUtil.assertOnUiThread(); mLifecycleState = LifecycleState.BEFORE_CREATE; for (LifecycleEventListener listener : mLifecycleEventListeners) { - listener.onHostDestroy(); + try { + listener.onHostDestroy(); + } catch (RuntimeException e) { + handleException(e); + } } mCurrentActivity = null; } @@ -258,7 +277,11 @@ public class ReactContext extends ContextWrapper { */ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { for (ActivityEventListener listener : mActivityEventListeners) { - listener.onActivityResult(activity, requestCode, resultCode, data); + try { + listener.onActivityResult(activity, requestCode, resultCode, data); + } catch (RuntimeException e) { + handleException(e); + } } }