Reputation: 61
I have a login page and then a home page, then I have an exit button on the home page. When you press the exit, I need the app to close.
If I use finish()
on the home page's exit onClick()
,it just take me back to the login page.
So I am using
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Now this does act like an exit but when you start the application again, it by passes the login screen and directly goes to the home page (as the app was never closed). What would be the best solution here?
Upvotes: 0
Views: 103
Reputation: 1006869
What would be the best solution here?
The best solution would be to delete the exit button and its associated functionality.
First, it is not necessary, as what you are providing with the exit button is already provided via the HOME button on the device.
Second, you have been told, repeatedly, by Googlers, not to have such a button.
See also: Is quitting an application frowned upon?
Upvotes: 3
Reputation: 15392
Before Coming to HomePage from Login Page use finish();
Intent i = new Intent(Login.this, Home.class);
StartActivity(i);
finish();
Upvotes: 1