onBackPressed() not working

后端 未结 5 979
独厮守ぢ
独厮守ぢ 2021-01-07 11:05

I\'m trying to close my app on a back button click. From the main screen, the back button takes you to a credits screen. From that credits screen, I want to close the app w

5条回答
  •  攒了一身酷
    2021-01-07 11:53

    Sorry, i am not able to comment yet (I wanted this to be a comment on Muffinbubble's answer)..

    Try putting the onKeyDown into your mainclass and validate if this get's called even if you are in your second Activity. You could then check where you are via the main class and exit the application if needed and else return super.onKeyDown(..).

提交回复
热议问题