So i have a button in the bottom layout , when i press it i intend to close the application.
instead what seems to happen is, what i think is the viewflipper closes and the bottom and top bar remain active and the application doesn't close.
this is the result when i press the Close button.
CODE
finish();
As per the documentation, finish()
closes the Activity that you call finish()
on, not your entire application.
Say you have two Activities, ActivityOne
and ActivityTwo
. ActivityOne
calls startActivity(new Intent(this, ActivityTwo.class))
to start ActivityTwo
. If you now call finish()
within ActivityTwo
, the first activity will be displayed again.
This is tied to the back stack - when you finish one Activity, the next Activity on the back stack will be displayed.
If you want to close all of your Activities, you must call finish()
on each of those Activities.
You can use
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startMain.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startMain.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
try to add
System.exit(0);
after finish();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.