Answer the question
In order to leave comments, you need to log in
How to override back button press in application?
Bottom line: I have an application that works in one activity and without fragments. The entire interface is drawn programmatically, control is done using the TouchListener, switching between application screens is done by replacing View in Layout.
Now, when I press the hardware Back button, I simply close the only Activity and, accordingly, the application, is it possible to override the purpose of the back button, so that, for example, when it is pressed, the current View is replaced with the main one (which opens when the application starts), and if the main View is launched, closed applications occur ?
Answer the question
In order to leave comments, you need to log in
Yes, you can, onBackPressed for the activity. But in general, this is all a so-so idea.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question