Skip to content

Commit b76c5b8

Browse files
author
Artur Chrusciel
committed
Check for activity finishing and destroyed on dialog dismiss
1 parent ddca267 commit b76c5b8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

android/src/main/java/org/devio/rn/splashscreen/SplashScreen.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,24 @@ public static void hide(Activity activity) {
7070
}
7171
activity = mActivity.get();
7272
}
73+
7374
if (activity == null) return;
7475

75-
activity.runOnUiThread(new Runnable() {
76+
final Activity _activity = activity;
77+
78+
_activity.runOnUiThread(new Runnable() {
7679
@Override
7780
public void run() {
78-
if (mSplashDialog != null && mSplashDialog.isShowing()) {
79-
mSplashDialog.dismiss();
81+
if (mSplashDialog != null && mSplashDialog.isShowing() && !_activity.isFinishing()) {
82+
boolean isDestroyed = false;
83+
84+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
85+
isDestroyed = _activity.isDestroyed();
86+
}
87+
88+
if (!isDestroyed) {
89+
mSplashDialog.dismiss();
90+
}
8091
mSplashDialog = null;
8192
}
8293
}

0 commit comments

Comments
 (0)