0

Is it possible to make Android application, which can be closed only by buttons in a layout of that app and not with back&home HW/SW buttons?

I want to make one-purpose app for myself, I can set all permissions for the app.

Xdg
  • 1,735
  • 2
  • 27
  • 42

3 Answers3

1

You shouldn't be doing that. That's the whole purpose and concept of the Home button. If you could explain your use-case, may be there are alternate approaches.

Kumar Bibek
  • 9,016
  • 2
  • 39
  • 68
1

In your current activity you can overide back buttons function using onBackPressed method.

When you press Home button, onPause method will be called (activity goes to paused stage). so you can overide it with your custom codes.

Jay Mayu
  • 17,023
  • 32
  • 114
  • 148
0

Back button- override onBackPressed and do not call super.onBackPressed. I don't think you can do home, but you can try trapping the keystroke.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127