package com.helloworld;

import android.os.Bundle;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

import expo.modules.ReactActivityDelegateWrapper;

public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Set the theme to AppTheme BEFORE onCreate to support 
    // coloring the background, status bar, and navigation bar.
    // This is required for expo-splash-screen.
    setTheme(R.style.AppTheme);
    super.onCreate(null);
  }

  /**
   * Returns the name of the main component registered from JavaScript.
   * This is used to schedule rendering of the component.
   */
  @Override
  protected String getMainComponentName() {
    return "main";
  }

  @Override
  protected ReactActivityDelegate createReactActivityDelegate() {
    return new ReactActivityDelegateWrapper(
      this,
      new ReactActivityDelegate(this, getMainComponentName()) {
      @Override
      protected ReactRootView createRootView() {
        return new RNGestureHandlerEnabledRootView(MainActivity.this);
      }
    });
  }
}

@@ -18,16 +18,41 @@
 world;%0A%0A
+import android.os.Build;%0A
 import a
@@ -1257,11 +1257,762 @@
  %7D);%0A  %7D
+%0A%0A  /**%0A   * Align the back button behavior with Android S%0A   * where moving root activities to background instead of finishing activities.%0A   * @see %3Ca href=%22https://developer.android.com/reference/android/app/Activity#onBackPressed()%22%3EonBackPressed%3C/a%3E%0A   */%0A  @Override%0A  public void invokeDefaultOnBackPressed() %7B%0A    if (Build.VERSION.SDK_INT %3C= Build.VERSION_CODES.R) %7B%0A      if (!moveTaskToBack(false)) %7B%0A        // For non-root activities, use the default implementation to finish them.%0A        super.invokeDefaultOnBackPressed();%0A      %7D%0A      return;%0A    %7D%0A%0A    // Use the default back button implementation on Android S%0A    // because it's doing more than %7B@link Activity#moveTaskToBack%7D in fact.%0A    super.invokeDefaultOnBackPressed();%0A  %7D
 %0A%7D%0A

Align Android back button behavior with classic build (#15378)