Replace deprecated onBackPressed with onBackPressedDispatcher (#3389)

Replaced deprecated `onBackPressed` with `onBackPressedDispatcher`. The `onBackPressedDispatcher` handles the home button press by delegating to the appropriate back navigation method.
This commit is contained in:
Tamim Hossain authored and GitHub committed 2024-07-31 20:36:52 +08:00
1 parent 804e425a87
commit cf9e830cc7
2 files changed
+4 -2

No files matched your search

@@ -23,7 +23,9 @@ abstract class BaseActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
android.R.id.home -> {
onBackPressed()
// Handles the home button press by delegating to the onBackPressedDispatcher.
// This ensures consistent back navigation behavior.
onBackPressedDispatcher.onBackPressed()
true
}
else -> super.onOptionsItemSelected(item)