Skip to content

Commit

Permalink
Fix BadTokenException when displaying warning messages
Browse files Browse the repository at this point in the history
Reviewed By: achen1

Differential Revision: D6651871

fbshipit-source-id: fc7fc118999f0e752636a3142764bd3496e5dc81
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jan 6, 2018
1 parent 46be5bf commit 0356cbd
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package com.facebook.react.devsupport;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
Expand Down Expand Up @@ -371,8 +372,8 @@ private void showNewError(
@Override
public void run() {
if (mRedBoxDialog == null) {
Context context = mReactInstanceManagerHelper.getCurrentActivity();
if (context == null) {
Activity context = mReactInstanceManagerHelper.getCurrentActivity();
if (context == null || context.isFinishing()) {
FLog.e(ReactConstants.TAG, "Unable to launch redbox because react activity " +
"is not available, here is the error that redbox would've displayed: " + message);
return;
Expand Down Expand Up @@ -518,8 +519,8 @@ public void onOptionSelected() {

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

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

0 comments on commit 0356cbd

Please sign in to comment.