diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 30f84700dbf0bd..3d5ee968202ac3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -27,6 +27,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; +import android.view.WindowInsets; import android.view.WindowManager; import android.widget.FrameLayout; import androidx.annotation.Nullable; @@ -826,9 +827,12 @@ private void checkForKeyboardEvents() { getRootView().getWindowVisibleDisplayFrame(mVisibleViewArea); int notchHeight = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - DisplayCutout displayCutout = getRootView().getRootWindowInsets().getDisplayCutout(); - if (displayCutout != null) { - notchHeight = displayCutout.getSafeInsetTop(); + WindowInsets insets = getRootView().getRootWindowInsets(); + if (insets != null) { + DisplayCutout displayCutout = insets.getDisplayCutout(); + if (displayCutout != null) { + notchHeight = displayCutout.getSafeInsetTop(); + } } } final int heightDiff =