1

I'm developing an Android app and I want that any user couldn't exit o press the back button from navigation bar to exit the app.

I've tried with the immersive mode and more but in this mode the user can slip the finger at the bottom of the screen and the navigation bar appears.

Anyone knows some way to block completely the navigation bar or prevent the user exit the application?

ligi
  • 39,001
  • 44
  • 144
  • 244
rlopezo
  • 425
  • 5
  • 16

1 Answers1

0

You can make the Back button do nothing. Override the following method in your Activity

@Override
public void onBackPressed() {
    // super.onBackPressed(); // this exits the activity among other things
}

Warning! Make sure you provide another visible way to exit the app. Generally what you're trying to do is a bad practice. User expects the Back button to behave in a certain way and this would confuse them. If I couldn't exit the app any normal way I'd be quite angry and remove it within a minute.

Eugen Pechanec
  • 37,669
  • 7
  • 103
  • 124
  • Hi, thank you. I understand what you say but in my case the app will be running permanently on a tablet fixed inside a "totem" like in the museums for explore content. Is for that, I don't want the user can exit the app. Do you konw what are the method launched when the user press the home button and the processes button on the navigation bar? I would need block this too. – rlopezo Oct 01 '14 at 09:35
  • I see, in that case you might want to check [this](http://stackoverflow.com/questions/2868047/fullscreen-activity-in-android). It should hide status and navigation bars. I haven't tried it though. – Eugen Pechanec Oct 01 '14 at 09:45
  • This is for the action bar, in my case this solution hides the navigation bar but the user can touch the screen and turn visible the navigation bar slipping the finger at the bottom of the screen, it is not a good solution in my case :( – rlopezo Oct 01 '14 at 09:49
  • If I could override the called methods for all the navigation bar buttons the problem will be resolved. – rlopezo Oct 01 '14 at 09:49
  • No, I meant [this answer](http://stackoverflow.com/a/2868052/2444099). It's not immersive mode, it's fullscreen. It hides status bar and navigation bar. Only downside is you can't use action bar then. – Eugen Pechanec Oct 01 '14 at 09:54
  • Thank for your help but I have been testing a reading and seems to be no way to block the home button action, you can detect when it is pressed in several ways but not block its action and prevent exit app. – rlopezo Oct 01 '14 at 10:40