Android: onBackPressed() not being called when navigation drawer open

前端 未结 8 1909
粉色の甜心
粉色の甜心 2021-02-05 05:54

I have a main activity that is situated with two navigation drawers. The left one is always accessible, but the right one is used for displaying some necessary lists and perform

8条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 06:37

    Quoting myself from the question at Force EditText to lose focus when back pressed

    "In my experience onBackPressed() (at least the default @Override one in an activity) will not normally fire when pushing the back button to close the keyboard. As far as I know it will only fire when a Back press would initiate a finish() on the current activity."

    This probably applies the same way to the navigation drawer.

    This is most likely due to the fact that the current "Activity" is not in focus when the drawer opens (same with the SoftKeyboard) so the @Override back button is not called.

提交回复
热议问题