Why isn't onBackPressed in my MainActivity being called?

Viewed 16

I've written a simple launcher, and I've gotten everything to work except handling back button presses. The app is a simple activity that switches between different fragments depending on the current state.

In my MainActivity, I have

override fun onBackPressed() {
    Log.d("MainActivity", "Back button pressed")
    // logic here
    super.onBackPressed()
}

But the method is never called. If I'm running logcat when pressing the back button on my (AVD) phone, I get the following messages:

09-07 19:52:23.673   557   670 W InputDispatcher: Unresponsive window Window{f90af54 u0 NavigationBar0} will not get the new gesture at 12714399818000
09-07 19:52:23.674   557   670 I InputDispatcher: Dropping event because there is no touchable window or gesture monitor at (229, 2137) in display 0.
09-07 19:52:23.751   557   670 I InputDispatcher: Dropping event because there is no touched foreground window in display 0 or gesture monitor to receive it.

I've tried googling it, but there are no relevant results to be found.

0 Answers
Related