Skip to content

Commit 67ee8dd

Browse files
authored
update Android doc to use OnBackPressedDispatcher instead of deprecated onBackPressed (#4663)
1 parent 42cff2c commit 67ee8dd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/integration-with-android-fragment.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ This is required by React Native to handle the back button press event.
3333

3434
Go into your host activity and make sure it implements the `DefaultHardwareBackBtnHandler` interface:
3535

36+
> **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.
37+
3638
<Tabs groupId="android-language" queryString defaultValue={constants.defaultAndroidLanguage} values={constants.androidLanguages}>
3739
<TabItem value="kotlin">
3840

@@ -56,7 +58,7 @@ import androidx.appcompat.app.AppCompatActivity
5658
}
5759

5860
+ override fun invokeDefaultOnBackPressed() {
59-
+ super.onBackPressed()
61+
+ onBackPressedDispatcher.onBackPressed()
6062
+ }
6163
}
6264
```
@@ -86,7 +88,7 @@ import androidx.appcompat.app.AppCompatActivity;
8688

8789
+ @Override
8890
+ public void invokeDefaultOnBackPressed() {
89-
+ super.onBackPressed();
91+
+ getOnBackPressedDispatcher().onBackPressed();
9092
+ }
9193
}
9294
```

0 commit comments

Comments
 (0)