diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java index 0f5aa1af34f868..8e7007c9b13609 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java @@ -69,8 +69,6 @@ import com.facebook.soloader.SoLoader; import com.facebook.systrace.Systrace; -import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_JS_MODULE_CONFIG_END; -import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_JS_MODULE_CONFIG_START; import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_NATIVE_MODULE_REGISTRY_END; import static com.facebook.react.bridge.ReactMarkerConstants.BUILD_NATIVE_MODULE_REGISTRY_START; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_CATALYST_INSTANCE_END; @@ -480,6 +478,8 @@ public void onNewIntent(Intent intent) { Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class); deviceEventManagerModule.emitNewIntentReceived(uri); } + + mCurrentReactContext.onNewIntent(mCurrentActivity, intent); } } @@ -519,7 +519,6 @@ public void onHostPause() { public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) { UiThreadUtil.assertOnUiThread(); - mDefaultBackButtonImpl = defaultBackButtonImpl; if (mUseDeveloperSupport) { mDevSupportManager.setDevSupportEnabled(true); @@ -852,7 +851,6 @@ private ReactApplicationContext createReactContext( ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_END); } - NativeModuleCallExceptionHandler exceptionHandler = mNativeModuleCallExceptionHandler != null ? mNativeModuleCallExceptionHandler : mDevSupportManager; diff --git a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java index ff897d21961d15..588cd37f2c951a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java @@ -463,6 +463,8 @@ public void onNewIntent(Intent intent) { Assertions.assertNotNull(mCurrentReactContext).getNativeModule(DeviceEventManagerModule.class); deviceEventManagerModule.emitNewIntentReceived(uri); } + + mCurrentReactContext.onNewIntent(mCurrentActivity, intent); } } @@ -862,7 +864,6 @@ private ReactApplicationContext createReactContext( catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener); } - ReactMarker.logMarker(RUN_JS_BUNDLE_START); try { catalystInstance.getReactQueueConfiguration().getJSQueueThread().callOnQueue( diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java index 3f45b4ce8105f3..888a66a0ee74e5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java @@ -13,4 +13,9 @@ public interface ActivityEventListener { * Called when host (activity/service) receives an {@link Activity#onActivityResult} call. */ void onActivityResult(int requestCode, int resultCode, Intent data); + + /** + * Called when a new intent is passed to the activity + */ + void onNewIntent(Intent intent); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java new file mode 100644 index 00000000000000..6a5740ea3f606c --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java @@ -0,0 +1,17 @@ +// Copyright 2004-present Facebook. All Rights Reserved. + +package com.facebook.react.bridge; + +import android.content.Intent; + +/** + * An empty implementation of {@link ActivityEventListener} + */ +public class BaseActivityEventListener implements ActivityEventListener { + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { } + + @Override + public void onNewIntent(Intent intent) { } +} 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 360a95f8d9961c..8f1b389897756b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -162,6 +162,14 @@ public void onHostResume(@Nullable Activity activity) { } } + public void onNewIntent(@Nullable Activity activity, Intent intent) { + UiThreadUtil.assertOnUiThread(); + mCurrentActivity = new WeakReference(activity); + for (ActivityEventListener listener : mActivityEventListeners) { + listener.onNewIntent(intent); + } + } + /** * Should be called by the hosting Fragment in {@link Fragment#onPause} */