0

Hi i need something to don't let users exit my app without pressing the button exit. Basicly if they use home or any other button the app can't exit. How can i make this? Im using android studio and im new to this language.

  • 3
    you can control only the backbutton, But I think you cant control the home unless the phone is jail break. – Rod_Algonquin Apr 26 '16 at 13:27
  • 2
    see this link http://stackoverflow.com/questions/17549478/how-to-disable-home-and-other-system-buttons-in-android – N J Apr 26 '16 at 13:29
  • 4
    Sounds like a sufficiently annoying feature that you wouldn't have to worry about having users for long... – Andy Turner Apr 26 '16 at 13:29
  • 1
    I saw some apps where it is not possible to leave by back button press. And this alone is absolutely annoying. I would directly remove the app and give the worst vote on such an app. So you must have a very good reason for this and (if you make it possible) tell your users WHY it´s not possible to leave.... – Opiatefuchs Apr 26 '16 at 13:31
  • I need because its an app for workers in a company and they can't leave the app without pressing the button – André Marques Apr 26 '16 at 13:31
  • 1
    so it is restricted by the company to leave that app and it is a comapny device, you mean? This would be a good reason. Anyway, without rooting, you can´t. The only thing you can do is to override onBackPressed() but this doesn´t avoid to leave by home button. – Opiatefuchs Apr 26 '16 at 13:32
  • yes they will have an cellphone but they can't leave app without finish session. so thats why i need to not let them exit except they click my button to leave. – André Marques Apr 26 '16 at 13:34

1 Answers1

0

The only thing you can do is override the onBackPressed method but unfortunately, you can't stop the home button from closing the app unless the phone is rooted or something. But when you do close the app with the home button it is still in Android's memory which prevents cold starts the next time the user opens the app. I am not sure why the information would be helpful though.

potato
  • 21
  • 6