S
S
spartan212018-10-26 14:45:13
Android
spartan21, 2018-10-26 14:45:13

How to disable the back button in the application?

I added a pin code entry window to the application, but when the back button is pressed, the pin code entry window closes and the user enters the application without entering the pin code.
How can I disable the back button in the application?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
azShoo, 2018-10-26
@spartan21

Make an override to call onBackPressed and/or KeyEvent.KEYCODE_BACK with an empty\action you need.
Although it looks like a crutch, and the situation you describe should be solved in other ways.

O
Oleg, 2018-10-26
@402d

I would not disable the back button. Do you already have a successor from AndroidApplication ?
Needed as a common storage for all activities.
It has a static method PinEntered()
In the remaining activities, when they come to the fore, MyApp.PinEntered() would check
and if not, then enter it.
You can write your own activity class with this functionality and inherit everything from it, except for the activity pin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question