diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index 70990d838aaf49..a5b0da68eeafcf 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -121,7 +121,7 @@ protected void onDestroy() { public void onActivityResult(int requestCode, int resultCode, Intent data) { if (getReactNativeHost().hasInstance()) { getReactNativeHost().getReactInstanceManager() - .onActivityResult(requestCode, resultCode, data); + .onActivityResult(getPlainActivity(), requestCode, resultCode, data); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index ad23ebf566f7eb..f5d1b9f5735be8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -146,7 +146,11 @@ public abstract void onHostResume( */ public abstract void onHostDestroy(Activity activity); - public abstract void onActivityResult(int requestCode, int resultCode, Intent data); + public abstract void onActivityResult( + Activity activity, + int requestCode, + int resultCode, + Intent data); public abstract void showDevOptionsDialog(); /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java index 6be0933125c6aa..d2c02aefc09f57 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java @@ -607,9 +607,9 @@ private void moveToBeforeCreateLifecycleState() { } @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { if (mCurrentReactContext != null) { - mCurrentReactContext.onActivityResult(requestCode, resultCode, data); + mCurrentReactContext.onActivityResult(activity, requestCode, resultCode, data); } } 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 888a66a0ee74e5..834b2267eb2fd5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ActivityEventListener.java @@ -2,17 +2,19 @@ package com.facebook.react.bridge; +import android.app.Activity; import android.content.Intent; /** - * Listener for receiving activity events. + * Listener for receiving activity events. Consider using {@link BaseActivityEventListener} if + * you're not interested in all the events sent to this interface. */ public interface ActivityEventListener { /** * Called when host (activity/service) receives an {@link Activity#onActivityResult} call. */ - void onActivityResult(int requestCode, int resultCode, Intent data); + void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data); /** * Called when a new intent is passed to the activity diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java index 6a5740ea3f606c..a855e21bb440ee 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java @@ -2,6 +2,7 @@ package com.facebook.react.bridge; +import android.app.Activity; import android.content.Intent; /** @@ -9,9 +10,15 @@ */ public class BaseActivityEventListener implements ActivityEventListener { - @Override + /** + * @deprecated use {@link #onActivityResult(Activity, int, int, Intent)} instead. + */ + @Deprecated public void onActivityResult(int requestCode, int resultCode, Intent data) { } + @Override + public void onActivityResult(Activity activity, 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 e96dbc3abf32a2..8a86668837aeda 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -205,9 +205,9 @@ public void destroy() { /** * Should be called by the hosting Fragment in {@link Fragment#onActivityResult} */ - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { for (ActivityEventListener listener : mActivityEventListeners) { - listener.onActivityResult(requestCode, resultCode, data); + listener.onActivityResult(activity, requestCode, resultCode, data); } }