Fix BadTokenException when displaying warning messages

Reviewed By: achen1

Differential Revision: D6651871

fbshipit-source-id: fc7fc118999f0e752636a3142764bd3496e5dc81
This commit is contained in:
David Vacca 2018-01-05 15:46:56 -08:00 committed by Facebook Github Bot
parent 46be5bf71c
commit 0356cbd13b
1 changed files with 5 additions and 4 deletions

View File

@ -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;
@ -371,8 +372,8 @@ public class DevSupportManagerImpl implements
@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;
@ -518,8 +519,8 @@ public class DevSupportManagerImpl implements
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;