Android - prevent the user from closing the application

I have an Android application that will be used in a restaurant, so I want users to not be able to exit the application. The only thing users can use is the application.

(If possible, only the administrator can exit the application by logging in or rebooting the device, I do not know which one is best).

Is there a solution or other way to do this?

Many thanks!

+8
source share
3 answers

What you are looking for is a kiosk mode application, I remember that I read that in 4.2 you can write an application for the home screen, which in behavior will work as follows:

http://commonsware.com/blog/2013/02/20/android-4p2-for-kiosk-apps.html

+4

override onBackPressed

@Override 
public void onBackPressed(){  
  Toast.MakeText(getApplicationContext(),"You Are Not Allowed to Exit the App", Toast.LENGTH_SHORT).show();
}

.

override home button,

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_HOME) {
        Log.i("TEST", "Home Button");  // here you'll have to do something to prevent the button to go to the home screen 
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

EDIT: android 4.0.xx override recent apps button , .

+2