Skip to content

Commit 0356cbd

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix BadTokenException when displaying warning messages
Reviewed By: achen1 Differential Revision: D6651871 fbshipit-source-id: fc7fc118999f0e752636a3142764bd3496e5dc81
1 parent 46be5bf commit 0356cbd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package com.facebook.react.devsupport;
1111

12+
import android.app.Activity;
1213
import android.app.ActivityManager;
1314
import android.app.AlertDialog;
1415
import android.content.BroadcastReceiver;
@@ -371,8 +372,8 @@ private void showNewError(
371372
@Override
372373
public void run() {
373374
if (mRedBoxDialog == null) {
374-
Context context = mReactInstanceManagerHelper.getCurrentActivity();
375-
if (context == null) {
375+
Activity context = mReactInstanceManagerHelper.getCurrentActivity();
376+
if (context == null || context.isFinishing()) {
376377
FLog.e(ReactConstants.TAG, "Unable to launch redbox because react activity " +
377378
"is not available, here is the error that redbox would've displayed: " + message);
378379
return;
@@ -518,8 +519,8 @@ public void onOptionSelected() {
518519

519520
final DevOptionHandler[] optionHandlers = options.values().toArray(new DevOptionHandler[0]);
520521

521-
Context context = mReactInstanceManagerHelper.getCurrentActivity();
522-
if (context == null) {
522+
Activity context = mReactInstanceManagerHelper.getCurrentActivity();
523+
if (context == null || context.isFinishing()) {
523524
FLog.e(ReactConstants.TAG, "Unable to launch dev options menu because react activity " +
524525
"isn't available");
525526
return;

0 commit comments

Comments
 (0)