mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-08 18:23:13 +08:00
check lifecycle event is coming from current activity
Summary: If a paused activity is destroyed (e.g. because of resource contention), we send onHostDestroyed to all modules even if there's an on-screen, resumed activity using the current react instance. This diff adds a check to make sure lifecycle events come from the current activity, and ignores ones that don't. Reviewed By: astreet Differential Revision: D3655422 fbshipit-source-id: 0f95fda124df3732447853b9bc34c40836a4b1da
This commit is contained in:
committed by
Facebook Github Bot 1
parent
46dc46a3b3
commit
0b5c61250b
@@ -97,8 +97,22 @@ public abstract class ReactInstanceManager {
|
||||
/**
|
||||
* Call this from {@link Activity#onPause()}. This notifies any listening modules so they can do
|
||||
* any necessary cleanup.
|
||||
*
|
||||
* @deprecated Use {@link #onHostPause(Activity)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void onHostPause();
|
||||
|
||||
/**
|
||||
* Call this from {@link Activity#onPause()}. This notifies any listening modules so they can do
|
||||
* any necessary cleanup. The passed Activity is the current Activity being paused. This will
|
||||
* always be the foreground activity that would be returned by
|
||||
* {@link ReactContext#getCurrentActivity()}.
|
||||
*
|
||||
* @param activity the activity being paused
|
||||
*/
|
||||
public abstract void onHostPause(Activity activity);
|
||||
|
||||
/**
|
||||
* Use this method when the activity resumes to enable invoking the back button directly from JS.
|
||||
*
|
||||
@@ -117,8 +131,21 @@ public abstract class ReactInstanceManager {
|
||||
/**
|
||||
* Call this from {@link Activity#onDestroy()}. This notifies any listening modules so they can do
|
||||
* any necessary cleanup.
|
||||
*
|
||||
* @deprecated use {@link #onHostDestroy(Activity)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void onHostDestroy();
|
||||
|
||||
/**
|
||||
* Call this from {@link Activity#onDestroy()}. This notifies any listening modules so they can do
|
||||
* any necessary cleanup. If the activity being destroyed is not the current activity, no modules
|
||||
* are notified.
|
||||
*
|
||||
* @param activity the activity being destroyed
|
||||
*/
|
||||
public abstract void onHostDestroy(Activity activity);
|
||||
|
||||
public abstract void onActivityResult(int requestCode, int resultCode, Intent data);
|
||||
public abstract void showDevOptionsDialog();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user