From b094fffa9319f994b1ea48f9f9bb40eeae077d49 Mon Sep 17 00:00:00 2001 From: Alan Lee Date: Mon, 23 Jun 2025 18:15:18 -0700 Subject: [PATCH 1/2] update Android doc to use OnBackPressedDispatcher instead of deprecated onBackPressed --- docs/integration-with-android-fragment.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/integration-with-android-fragment.md b/docs/integration-with-android-fragment.md index 541fe6a2ec7..db19a5e92d4 100644 --- a/docs/integration-with-android-fragment.md +++ b/docs/integration-with-android-fragment.md @@ -33,6 +33,8 @@ This is required by React Native to handle the back button press event. Go into your host activity and make sure it implements the `DefaultHardwareBackBtnHandler` interface: +> **Deprecated.** `Activity.onBackPressed()` has been [deprecated](https://developer.android.com/reference/android/app/Activity#onBackPressed()) since API level 33. Android 16 devices with apps targeting API level 36 this will [no longer be called](https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back) and [OnBackPressedDispatcher](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher) should be used instead. + @@ -56,7 +58,7 @@ import androidx.appcompat.app.AppCompatActivity } + override fun invokeDefaultOnBackPressed() { -+ super.onBackPressed() ++ onBackPressedDispatcher.onBackPressed() + } } ``` @@ -86,7 +88,7 @@ import androidx.appcompat.app.AppCompatActivity; + @Override + public void invokeDefaultOnBackPressed() { -+ super.onBackPressed(); ++ getOnBackPressedDispatcher().onBackPressed(); + } } ``` From f4501f5011887879227485fb7817c0b1077afd35 Mon Sep 17 00:00:00 2001 From: Alan Lee Date: Mon, 23 Jun 2025 22:15:31 -0700 Subject: [PATCH 2/2] fix lint error --- docs/integration-with-android-fragment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/integration-with-android-fragment.md b/docs/integration-with-android-fragment.md index db19a5e92d4..ea086300342 100644 --- a/docs/integration-with-android-fragment.md +++ b/docs/integration-with-android-fragment.md @@ -33,7 +33,7 @@ This is required by React Native to handle the back button press event. Go into your host activity and make sure it implements the `DefaultHardwareBackBtnHandler` interface: -> **Deprecated.** `Activity.onBackPressed()` has been [deprecated](https://developer.android.com/reference/android/app/Activity#onBackPressed()) since API level 33. Android 16 devices with apps targeting API level 36 this will [no longer be called](https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back) and [OnBackPressedDispatcher](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher) should be used instead. +> **Deprecated.** `Activity.onBackPressed()` has been [deprecated]() since API level 33. Android 16 devices with apps targeting API level 36 this will [no longer be called](https://developer.android.com/about/versions/16/behavior-changes-16#predictive-back) and [OnBackPressedDispatcher](https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher) should be used instead.