Skip to content

Commit

Permalink
Fix currentActivity being null when launching Redbox
Browse files Browse the repository at this point in the history
Summary:
Try to reuse currentActivity when the new context from "mReactInstanceDevHelper.getCurrentActivity()" is null to fix  "Unable to launch redbox because react activity is not available..."

Changelog:
[Android][Fixed] - Fix currentActivity being null when launching Redbox

Reviewed By: philIip

Differential Revision: D30942434

fbshipit-source-id: faf03390adc545376f3cec223eac5a16bf8233ea
  • Loading branch information
luluwu2032 authored and facebook-github-bot committed Sep 20, 2021
1 parent c0e0446 commit f4fdf4b
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,21 @@ private void showNewError(
@Override
public void run() {
Activity context = mReactInstanceDevHelper.getCurrentActivity();
if (mRedBoxDialog == null || context != currentActivity) {
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;
}
if (context != null && !context.isFinishing() && currentActivity != context) {
currentActivity = context;
// Create a new RedBox when currentActivity get updated
mRedBoxDialog =
new RedBoxDialog(currentActivity, DevSupportManagerBase.this, mRedBoxHandler);
}
if (currentActivity == null || currentActivity.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;
}
if (mRedBoxDialog == null) {
mRedBoxDialog =
new RedBoxDialog(currentActivity, DevSupportManagerBase.this, mRedBoxHandler);
}
Expand Down

1 comment on commit f4fdf4b

@vamper424
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current Activity es ordinario y primordial para el desarrollador óptimo de react native y pues también es tecnológico al 200 % gracias por participar Facebook.

Please sign in to comment.