onBackPressed() deprecated in Android 13 (Tiramisu). How to properly handle the Back button press?
Hello everyone! I just started learning Android development in Kotlin and ran into a problem. My app has several screens (fragments), and I need to override the Back button behavior. Previously, I used this code:
```kotlin
override fun onBackPressed() {
if (someCondition) {
super.onBackPressed()
} else {
showExitConfirmationDialog()
}
}
```
But now Android Studio highlights `onBackPressed()` in yellow and says "Deprecated in Java". I read that this is related to Android 13 (Tiramisu). I tried using `OnBackPressedDispatcher`, but I can't figure out how to properly set it up. My project uses the `androidx.activity:activity-ktx:1.7.0` library.
I need:
1. On the main screen, when pressing Back, a dialog should appear