I've an android application that will be used in a restaurant, so I want that users can't exit from the app. The only thing that users can, is using application.
(If possible only admin can exit from app, by logging in or restarting device, I don't know which is the best way).
Is there a solution or other way to do this?
Open the Settings and find the “Apps” section. From the app's information page, select “Force Stop” or “Force Close.”
What happens when you close apps on Android? Closing an app stops it from running in the background. It won't sign you out of any apps, but opening the app again will start a new instance. You will need to keep an app running in the background if you want to continue where you left off.
Close one app: Swipe up from the bottom, hold, then let go. Swipe up on the app. Close all apps: Swipe up from the bottom, hold, then let go. Swipe from left to right.
you can override
the onBackPressed
method
@Override
public void onBackPressed(){
Toast.MakeText(getApplicationContext(),"You Are Not Allowed to Exit the App", Toast.LENGTH_SHORT).show();
}
this will prevent the back button from exiting the application.
and then you will need to override
the home button
as well like
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: for new devices with android version 4.0.xx you'll have to override
the recent apps button
as well
hope that helps you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With